lucid-extension-sdk 0.0.20 → 0.0.28

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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/sdk/commandtypes.d.ts +56 -0
  3. package/sdk/commandtypes.js +4 -0
  4. package/sdk/core/checks.js +1 -1
  5. package/sdk/core/data/serializedfield/serializedfields.js +1 -1
  6. package/sdk/core/properties/cardintegration.d.ts +85 -0
  7. package/sdk/core/properties/cardintegration.js +72 -0
  8. package/sdk/core/properties/datagraphic/badgeposition.d.ts +59 -0
  9. package/sdk/core/properties/datagraphic/badgeposition.js +122 -0
  10. package/sdk/core/properties/datagraphic/datagraphicindexes.d.ts +24 -0
  11. package/sdk/core/properties/datagraphic/datagraphicindexes.js +27 -0
  12. package/sdk/core/properties/datagraphic/staticdatagraphicsettings.d.ts +15 -0
  13. package/sdk/core/properties/datagraphic/staticdatagraphicsettings.js +28 -0
  14. package/sdk/core/properties/fillcolor.d.ts +65 -0
  15. package/sdk/core/properties/fillcolor.js +35 -0
  16. package/sdk/core/properties/shadow.d.ts +15 -0
  17. package/sdk/core/properties/shadow.js +23 -0
  18. package/sdk/data/dataitemproxy.d.ts +4 -0
  19. package/sdk/data/dataitemproxy.js +6 -0
  20. package/sdk/document/blockdefinition.d.ts +9 -0
  21. package/sdk/document/blockproxy.d.ts +48 -0
  22. package/sdk/document/blockproxy.js +89 -0
  23. package/sdk/document/documentproxy.d.ts +4 -0
  24. package/sdk/document/documentproxy.js +10 -0
  25. package/sdk/document/pageproxy.js +6 -0
  26. package/sdk/document/shapedataproxy.d.ts +5 -0
  27. package/sdk/document/shapedataproxy.js +12 -0
  28. package/sdk/document/taskmanagementcardintegration.d.ts +13 -0
  29. package/sdk/document/taskmanagementcardintegration.js +39 -0
  30. package/sdk/editorclient.js +13 -11
  31. package/sdk/ui/panel.d.ts +3 -1
  32. package/sdk/ui/panel.js +2 -0
  33. package/sdk/ui/viewport.d.ts +16 -0
  34. package/sdk/ui/viewport.js +37 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.28",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -17,12 +17,14 @@ import { PanelLocation } from './ui/panel';
17
17
  * To use these directly, use [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand).
18
18
  */
19
19
  export declare const enum CommandName {
20
+ AddCardIntegration = "aci",
20
21
  AddLineTextArea = "alta",
21
22
  AddMenuItem = "ami",
22
23
  AddShapeData = "asd",
23
24
  Alert = "a",
24
25
  AnimateViewport = "av",
25
26
  Bootstrap = "b",
27
+ CancelDragBlockToCanvas = "cdc",
26
28
  Confirm = "c",
27
29
  CreateBlock = "cb",
28
30
  CreateCollection = "cc",
@@ -30,6 +32,7 @@ export declare const enum CommandName {
30
32
  CreateLine = "cl",
31
33
  CreatePage = "cp",
32
34
  DataAction = "da",
35
+ DataItemExists = "die",
33
36
  DeleteItem = "di",
34
37
  DeletePage = "dp",
35
38
  DeleteShapeData = "dsd",
@@ -81,6 +84,7 @@ export declare const enum CommandName {
81
84
  ShowModal = "sm",
82
85
  ShowPanel = "spn",
83
86
  SleepForTestCase = "sleep",
87
+ StartDragBlockToCanvas = "sdc",
84
88
  ThrowForTestCase = "throw",
85
89
  UnhookCreateItems = "uci",
86
90
  UnhookSelection = "us",
@@ -94,6 +98,10 @@ export declare const commandTitles: Map<CommandName, string>;
94
98
  * which command name you pass in as the first parameter.
95
99
  */
96
100
  export declare type CommandArgs = {
101
+ [CommandName.AddCardIntegration]: {
102
+ query: AddCardIntegrationQuery;
103
+ result: AddCardIntegrationResult;
104
+ };
97
105
  [CommandName.AddLineTextArea]: {
98
106
  query: AddLineTextAreaQuery;
99
107
  result: AddLineTextAreaResult;
@@ -118,6 +126,10 @@ export declare type CommandArgs = {
118
126
  query: BootstrapQuery;
119
127
  result: BootstrapResult;
120
128
  };
129
+ [CommandName.CancelDragBlockToCanvas]: {
130
+ query: CancelDragBlockToCanvasQuery;
131
+ result: CancelDragBlockToCanvasResult;
132
+ };
121
133
  [CommandName.Confirm]: {
122
134
  query: ConfirmQuery;
123
135
  result: ConfirmResult;
@@ -146,6 +158,10 @@ export declare type CommandArgs = {
146
158
  query: DataActionQuery;
147
159
  result: DataActionResult;
148
160
  };
161
+ [CommandName.DataItemExists]: {
162
+ query: DataItemExistsQuery;
163
+ result: DataItemExistsResult;
164
+ };
149
165
  [CommandName.DeleteItem]: {
150
166
  query: DeleteItemQuery;
151
167
  result: DeleteItemResult;
@@ -350,6 +366,10 @@ export declare type CommandArgs = {
350
366
  query: SleepForTestCaseQuery;
351
367
  result: SleepForTestCaseResult;
352
368
  };
369
+ [CommandName.StartDragBlockToCanvas]: {
370
+ query: StartDragBlockToCanvasQuery;
371
+ result: StartDragBlockToCanvasResult;
372
+ };
353
373
  [CommandName.ThrowForTestCase]: {
354
374
  query: ThrowForTestCaseQuery;
355
375
  result: ThrowForTestCaseResult;
@@ -367,6 +387,17 @@ export declare type CommandArgs = {
367
387
  result: UnhookTextEditResult;
368
388
  };
369
389
  };
390
+ export declare type AddCardIntegrationQuery = {
391
+ /** Title/name */
392
+ 'n': string;
393
+ /** Icon url */
394
+ 'u': string;
395
+ /** Callback to get field definitions for a given imported collection */
396
+ 'gf': string;
397
+ /** Show intro if user has not yet authorized this integration */
398
+ 'i'?: string;
399
+ };
400
+ export declare type AddCardIntegrationResult = undefined;
370
401
  export declare type AddLineTextAreaQuery = {
371
402
  /** Which line */
372
403
  'id': string;
@@ -438,6 +469,8 @@ export declare type BootstrapQuery = {
438
469
  'm'?: boolean;
439
470
  };
440
471
  export declare type BootstrapResult = Promise<void>;
472
+ export declare type CancelDragBlockToCanvasQuery = void;
473
+ export declare type CancelDragBlockToCanvasResult = undefined;
441
474
  export declare type ConfirmQuery = {
442
475
  /** Title; defaults to extension title */
443
476
  't'?: string;
@@ -521,6 +554,13 @@ export declare type RawDataActionResult = {
521
554
  'j': unknown;
522
555
  });
523
556
  export declare type DataActionResult = Promise<RawDataActionResult>;
557
+ export declare type DataItemExistsQuery = {
558
+ /** Collection ID to check */
559
+ 'c': string;
560
+ /** Primary key to check */
561
+ 'pk': string;
562
+ };
563
+ export declare type DataItemExistsResult = boolean;
524
564
  export declare type DeleteItemQuery = string;
525
565
  export declare type DeleteItemResult = boolean;
526
566
  export declare type DeletePageQuery = string;
@@ -834,6 +874,22 @@ export declare type ShowPanelQuery = {
834
874
  export declare type ShowPanelResult = undefined;
835
875
  export declare type SleepForTestCaseQuery = number;
836
876
  export declare type SleepForTestCaseResult = Promise<void>;
877
+ export declare type StartDragBlockToCanvasQuery = {
878
+ /** Class name of the block to create */
879
+ 'c': string;
880
+ /** Size of the block to create */
881
+ 'sz': {
882
+ 'w': number;
883
+ 'h': number;
884
+ };
885
+ /** Additional properties to set on the block being dragged */
886
+ 'p': {
887
+ [key: string]: JsonSerializable;
888
+ };
889
+ /** If specified, the stencil for a custom shape. Only valid if the class name is 'CustomBlock' */
890
+ 's'?: JsonSerializable | undefined;
891
+ };
892
+ export declare type StartDragBlockToCanvasResult = Promise<string | undefined>;
837
893
  export declare type ThrowForTestCaseQuery = number;
838
894
  export declare type ThrowForTestCaseResult = undefined | Promise<void>;
839
895
  export declare type UnhookCreateItemsQuery = {
@@ -4,18 +4,21 @@ exports.isRawSendXHRResponse = exports.commandTitles = void 0;
4
4
  const checks_1 = require("./core/checks");
5
5
  /** @ignore */
6
6
  exports.commandTitles = new Map([
7
+ ["aci" /* AddCardIntegration */, 'AddCardIntegration'],
7
8
  ["alta" /* AddLineTextArea */, 'AddLineTextArea'],
8
9
  ["ami" /* AddMenuItem */, 'AddMenuItem'],
9
10
  ["asd" /* AddShapeData */, 'AddShapeData'],
10
11
  ["a" /* Alert */, 'Alert'],
11
12
  ["av" /* AnimateViewport */, 'AnimateViewport'],
12
13
  ["b" /* Bootstrap */, 'Bootstrap'],
14
+ ["cdc" /* CancelDragBlockToCanvas */, 'CancelDragBlockToCanvas'],
13
15
  ["c" /* Confirm */, 'Confirm'],
14
16
  ["cb" /* CreateBlock */, 'CreateBlock'],
15
17
  ["cc" /* CreateCollection */, 'CreateCollection'],
16
18
  ["cds" /* CreateDataSource */, 'CreateDataSource'],
17
19
  ["cl" /* CreateLine */, 'CreateLine'],
18
20
  ["cp" /* CreatePage */, 'CreatePage'],
21
+ ["die" /* DataItemExists */, 'DataItemExists'],
19
22
  ["di" /* DeleteItem */, 'DeleteItem'],
20
23
  ["dp" /* DeletePage */, 'DeletePage'],
21
24
  ["dsd" /* DeleteShapeData */, 'DeleteShapeData'],
@@ -67,6 +70,7 @@ exports.commandTitles = new Map([
67
70
  ["sm" /* ShowModal */, 'ShowModal'],
68
71
  ["spn" /* ShowPanel */, 'ShowPanel'],
69
72
  ["sleep" /* SleepForTestCase */, 'SleepForTestCase'],
73
+ ["sdc" /* StartDragBlockToCanvas */, 'StartDragBlockToCanvas'],
70
74
  ["throw" /* ThrowForTestCase */, 'ThrowForTestCase'],
71
75
  ["uci" /* UnhookCreateItems */, 'UnhookCreateItems'],
72
76
  ["us" /* UnhookSelection */, 'UnhookSelection'],
@@ -160,6 +160,6 @@ function isUnknown(val) {
160
160
  }
161
161
  exports.isUnknown = isUnknown;
162
162
  function isPromise(val) {
163
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
163
+ return isObject(val) && isFunction(val['then']) && isFunction(val['catch']);
164
164
  }
165
165
  exports.isPromise = isPromise;
@@ -7,7 +7,7 @@ function isSerializedColorObjectFieldType(value) {
7
7
  }
8
8
  exports.isSerializedColorObjectFieldType = isSerializedColorObjectFieldType;
9
9
  function isSerializedLucidDictionary(value) {
10
- return (0, checks_1.isObject)(value) && Object.values(value).every(isSerializedFieldType);
10
+ return (0, checks_1.isObject)(value) && (0, checks_1.isObject)(value['dict']) && Object.values(value['dict']).every(isSerializedFieldType);
11
11
  }
12
12
  exports.isSerializedLucidDictionary = isSerializedLucidDictionary;
13
13
  function isSerializedLucidCurrency(value) {
@@ -0,0 +1,85 @@
1
+ import { CollectionProxy } from '../../data/collectionproxy';
2
+ /**
3
+ * When this field is displayed on a card shape, how should it be displayed?
4
+ */
5
+ export declare enum CardFieldDisplayType {
6
+ Text = 1,
7
+ TextBadge = 2,
8
+ ImageBadge = 3
9
+ }
10
+ export declare enum CardFieldDataType {
11
+ Text = 1,
12
+ Number = 2,
13
+ /** An enumerated list of options, stored as a string */
14
+ Option = 3,
15
+ Checkbox = 4
16
+ }
17
+ /** For fields with Option or ApiOption type, the label and value for each available option */
18
+ export interface ExtensionCardFieldOption {
19
+ label: string;
20
+ value: string;
21
+ }
22
+ export interface ExtensionCardFieldDefinition {
23
+ /** Data identifier */
24
+ fieldName: string;
25
+ /** The text to display on the menu item */
26
+ label: string;
27
+ /** Additional information we can provide to users */
28
+ description?: string;
29
+ /** How a field is displayed */
30
+ displayType: CardFieldDisplayType;
31
+ /** Data type backing the field */
32
+ dataType: CardFieldDataType;
33
+ /** If dataType is Option, the list of options available to choose from */
34
+ options?: ExtensionCardFieldOption[];
35
+ }
36
+ /** @ignore */
37
+ export declare type SerializedCardFieldOption = {
38
+ 'l': string;
39
+ 'v': string;
40
+ };
41
+ /** @ignore */
42
+ export declare function serializeCardFieldOption(option: ExtensionCardFieldOption): SerializedCardFieldOption;
43
+ /** @ignore */
44
+ export declare type SerializedExtensionCardFieldDefinition = {
45
+ 'n': string;
46
+ 't': string;
47
+ 'd'?: string;
48
+ 'diT': number;
49
+ 'daT': number;
50
+ 'op'?: SerializedCardFieldOption[];
51
+ };
52
+ /** @ignore */
53
+ export declare function serializeCardFieldDefinition(field: ExtensionCardFieldDefinition): SerializedExtensionCardFieldDefinition;
54
+ /** @ignore */
55
+ export declare function serializeCardFieldArrayDefinition(fields: ExtensionCardFieldDefinition[]): SerializedExtensionCardFieldDefinition[];
56
+ /** @ignore */
57
+ export declare function deseializeFieldOption(option: SerializedCardFieldOption): ExtensionCardFieldOption;
58
+ /** @ignore */
59
+ export declare function deserializeCardFieldDefinition(field: SerializedExtensionCardFieldDefinition): ExtensionCardFieldDefinition;
60
+ /** @ignore */
61
+ export declare function deserializeCardFieldArrayDefinition(fields: SerializedExtensionCardFieldDefinition[]): ExtensionCardFieldDefinition[];
62
+ export interface CardIntegration {
63
+ /**
64
+ * Label used to identify the integration, e.g. "Jira", which will be used in menu items, etc.
65
+ * Should be unique within any given extension.
66
+ */
67
+ label: string;
68
+ /**
69
+ * URL for an icon to display in toolbars, etc. Should be at least 24x24.
70
+ */
71
+ iconUrl: string;
72
+ /**
73
+ * Callback to provide a list of field definitions for the given collection, if that collection
74
+ * was imported as part of this card integration.
75
+ *
76
+ * Any fields on the schema of the collection that you don't provide a ExtensionCardFieldDefinition
77
+ * for will have a default definition generated based on the type specified in the schema.
78
+ */
79
+ getAllFields: (collection: CollectionProxy) => Promise<ExtensionCardFieldDefinition[]>;
80
+ /**
81
+ * If specified, and the user hasn't yet authorized the data connector for this extension,
82
+ * this should show the user an intro dialog or take some other action.
83
+ */
84
+ showIntro?: () => void;
85
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeCardFieldArrayDefinition = exports.deserializeCardFieldDefinition = exports.deseializeFieldOption = exports.serializeCardFieldArrayDefinition = exports.serializeCardFieldDefinition = exports.serializeCardFieldOption = exports.CardFieldDataType = exports.CardFieldDisplayType = void 0;
4
+ /**
5
+ * When this field is displayed on a card shape, how should it be displayed?
6
+ */
7
+ var CardFieldDisplayType;
8
+ (function (CardFieldDisplayType) {
9
+ CardFieldDisplayType[CardFieldDisplayType["Text"] = 1] = "Text";
10
+ CardFieldDisplayType[CardFieldDisplayType["TextBadge"] = 2] = "TextBadge";
11
+ CardFieldDisplayType[CardFieldDisplayType["ImageBadge"] = 3] = "ImageBadge";
12
+ })(CardFieldDisplayType = exports.CardFieldDisplayType || (exports.CardFieldDisplayType = {}));
13
+ var CardFieldDataType;
14
+ (function (CardFieldDataType) {
15
+ CardFieldDataType[CardFieldDataType["Text"] = 1] = "Text";
16
+ CardFieldDataType[CardFieldDataType["Number"] = 2] = "Number";
17
+ /** An enumerated list of options, stored as a string */
18
+ CardFieldDataType[CardFieldDataType["Option"] = 3] = "Option";
19
+ CardFieldDataType[CardFieldDataType["Checkbox"] = 4] = "Checkbox";
20
+ })(CardFieldDataType = exports.CardFieldDataType || (exports.CardFieldDataType = {}));
21
+ /** @ignore */
22
+ function serializeCardFieldOption(option) {
23
+ return {
24
+ 'l': option.label,
25
+ 'v': option.value,
26
+ };
27
+ }
28
+ exports.serializeCardFieldOption = serializeCardFieldOption;
29
+ /** @ignore */
30
+ function serializeCardFieldDefinition(field) {
31
+ var _a;
32
+ return {
33
+ 'n': field.fieldName,
34
+ 't': field.label,
35
+ 'd': field.description,
36
+ 'diT': field.displayType,
37
+ 'daT': field.dataType,
38
+ 'op': (_a = field.options) === null || _a === void 0 ? void 0 : _a.map(serializeCardFieldOption),
39
+ };
40
+ }
41
+ exports.serializeCardFieldDefinition = serializeCardFieldDefinition;
42
+ /** @ignore */
43
+ function serializeCardFieldArrayDefinition(fields) {
44
+ return fields.map(serializeCardFieldDefinition);
45
+ }
46
+ exports.serializeCardFieldArrayDefinition = serializeCardFieldArrayDefinition;
47
+ /** @ignore */
48
+ function deseializeFieldOption(option) {
49
+ return {
50
+ label: option['l'],
51
+ value: option['v'],
52
+ };
53
+ }
54
+ exports.deseializeFieldOption = deseializeFieldOption;
55
+ /** @ignore */
56
+ function deserializeCardFieldDefinition(field) {
57
+ var _a;
58
+ return {
59
+ fieldName: field['n'],
60
+ label: field['t'],
61
+ description: field['d'],
62
+ displayType: field['diT'],
63
+ dataType: field['daT'],
64
+ options: (_a = field['op']) === null || _a === void 0 ? void 0 : _a.map(deseializeFieldOption),
65
+ };
66
+ }
67
+ exports.deserializeCardFieldDefinition = deserializeCardFieldDefinition;
68
+ /** @ignore */
69
+ function deserializeCardFieldArrayDefinition(fields) {
70
+ return fields.map(deserializeCardFieldDefinition);
71
+ }
72
+ exports.deserializeCardFieldArrayDefinition = deserializeCardFieldArrayDefinition;
@@ -0,0 +1,59 @@
1
+ export declare enum HorizontalBadgePos {
2
+ LEFT = 0,
3
+ CENTER = 1,
4
+ RIGHT = 2
5
+ }
6
+ export declare enum VerticalBadgePos {
7
+ TOP = 0,
8
+ CENTER = 1,
9
+ BOTTOM = 2
10
+ }
11
+ export declare enum BadgeLayerPos {
12
+ INSIDE = 0,
13
+ EDGE = 1,
14
+ OUTSIDE = 2
15
+ }
16
+ export declare enum BadgeResponsiveness {
17
+ STATIC = 0,
18
+ STACK = 1
19
+ }
20
+ export interface BadgeEnumPosition {
21
+ horizontalPos: HorizontalBadgePos;
22
+ verticalPos: VerticalBadgePos;
23
+ layer: BadgeLayerPos;
24
+ responsive: BadgeResponsiveness;
25
+ }
26
+ export declare const BadgePositionsClockwise: {
27
+ horizontalPos: number;
28
+ verticalPos: number;
29
+ }[];
30
+ export declare type SerializedBadgeEnumPosition = {
31
+ 'horiz'?: HorizontalBadgePos;
32
+ 'vert'?: VerticalBadgePos;
33
+ 'layer'?: BadgeLayerPos;
34
+ 'responsive'?: BadgeResponsiveness;
35
+ };
36
+ export interface Badgeable {
37
+ position: SerializedBadgeEnumPosition;
38
+ }
39
+ export declare const defaultBadgePosition: {
40
+ horizontalPos: HorizontalBadgePos;
41
+ verticalPos: VerticalBadgePos;
42
+ layer: BadgeLayerPos;
43
+ responsive: BadgeResponsiveness;
44
+ };
45
+ export declare const defaultBadgePositionSerialized: {
46
+ horiz: HorizontalBadgePos;
47
+ vert: VerticalBadgePos;
48
+ layer: BadgeLayerPos;
49
+ responsive: BadgeResponsiveness;
50
+ };
51
+ export declare function badgePositionsEqual(a: BadgeEnumPosition, b: BadgeEnumPosition): boolean;
52
+ export declare function deserializeBadgeEnumPosition(serialized?: SerializedBadgeEnumPosition): BadgeEnumPosition;
53
+ export declare function deserializeBadgeEnumPosition(serialized?: SerializedBadgeEnumPosition | null): BadgeEnumPosition | undefined;
54
+ export declare function serializeBadgeEnumPosition(position?: BadgeEnumPosition | null): SerializedBadgeEnumPosition;
55
+ export declare function serializeBadgeEnumPositionAsKey(position: BadgeEnumPosition): string;
56
+ export declare function isValidSerializedBadgeEnumPosition(val: any): val is SerializedBadgeEnumPosition;
57
+ export declare function isHorizontalPos(maybePos: HorizontalBadgePos | undefined | null): maybePos is HorizontalBadgePos;
58
+ export declare function isVerticalPos(maybePos: VerticalBadgePos | undefined | null): maybePos is VerticalBadgePos;
59
+ export declare function isLayerPos(maybePos: BadgeLayerPos | undefined | null): maybePos is BadgeLayerPos;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLayerPos = exports.isVerticalPos = exports.isHorizontalPos = exports.isValidSerializedBadgeEnumPosition = exports.serializeBadgeEnumPositionAsKey = exports.serializeBadgeEnumPosition = exports.deserializeBadgeEnumPosition = exports.badgePositionsEqual = exports.defaultBadgePositionSerialized = exports.defaultBadgePosition = exports.BadgePositionsClockwise = exports.BadgeResponsiveness = exports.BadgeLayerPos = exports.VerticalBadgePos = exports.HorizontalBadgePos = void 0;
4
+ const checks_1 = require("../../checks");
5
+ var HorizontalBadgePos;
6
+ (function (HorizontalBadgePos) {
7
+ HorizontalBadgePos[HorizontalBadgePos["LEFT"] = 0] = "LEFT";
8
+ HorizontalBadgePos[HorizontalBadgePos["CENTER"] = 1] = "CENTER";
9
+ HorizontalBadgePos[HorizontalBadgePos["RIGHT"] = 2] = "RIGHT";
10
+ })(HorizontalBadgePos = exports.HorizontalBadgePos || (exports.HorizontalBadgePos = {}));
11
+ var VerticalBadgePos;
12
+ (function (VerticalBadgePos) {
13
+ VerticalBadgePos[VerticalBadgePos["TOP"] = 0] = "TOP";
14
+ VerticalBadgePos[VerticalBadgePos["CENTER"] = 1] = "CENTER";
15
+ VerticalBadgePos[VerticalBadgePos["BOTTOM"] = 2] = "BOTTOM";
16
+ })(VerticalBadgePos = exports.VerticalBadgePos || (exports.VerticalBadgePos = {}));
17
+ var BadgeLayerPos;
18
+ (function (BadgeLayerPos) {
19
+ BadgeLayerPos[BadgeLayerPos["INSIDE"] = 0] = "INSIDE";
20
+ BadgeLayerPos[BadgeLayerPos["EDGE"] = 1] = "EDGE";
21
+ BadgeLayerPos[BadgeLayerPos["OUTSIDE"] = 2] = "OUTSIDE";
22
+ })(BadgeLayerPos = exports.BadgeLayerPos || (exports.BadgeLayerPos = {}));
23
+ var BadgeResponsiveness;
24
+ (function (BadgeResponsiveness) {
25
+ BadgeResponsiveness[BadgeResponsiveness["STATIC"] = 0] = "STATIC";
26
+ BadgeResponsiveness[BadgeResponsiveness["STACK"] = 1] = "STACK";
27
+ })(BadgeResponsiveness = exports.BadgeResponsiveness || (exports.BadgeResponsiveness = {}));
28
+ /*
29
+ * The order of the badge position starting from the top-left corner and going clockwise
30
+ */
31
+ exports.BadgePositionsClockwise = [
32
+ { horizontalPos: 0, verticalPos: 0 },
33
+ { horizontalPos: 1, verticalPos: 0 },
34
+ { horizontalPos: 2, verticalPos: 0 },
35
+ { horizontalPos: 2, verticalPos: 1 },
36
+ { horizontalPos: 2, verticalPos: 2 },
37
+ { horizontalPos: 1, verticalPos: 2 },
38
+ { horizontalPos: 0, verticalPos: 2 },
39
+ { horizontalPos: 0, verticalPos: 1 }, // left-center
40
+ ];
41
+ exports.defaultBadgePosition = {
42
+ horizontalPos: HorizontalBadgePos.RIGHT,
43
+ verticalPos: VerticalBadgePos.TOP,
44
+ layer: BadgeLayerPos.EDGE,
45
+ responsive: BadgeResponsiveness.STACK,
46
+ };
47
+ exports.defaultBadgePositionSerialized = {
48
+ 'horiz': HorizontalBadgePos.RIGHT,
49
+ 'vert': VerticalBadgePos.TOP,
50
+ 'layer': BadgeLayerPos.EDGE,
51
+ 'responsive': BadgeResponsiveness.STACK,
52
+ };
53
+ function badgePositionsEqual(a, b) {
54
+ return (a.horizontalPos === b.horizontalPos &&
55
+ a.verticalPos === b.verticalPos &&
56
+ a.layer === b.layer &&
57
+ a.responsive === b.responsive);
58
+ }
59
+ exports.badgePositionsEqual = badgePositionsEqual;
60
+ function deserializeBadgeEnumPosition(serialized) {
61
+ if (serialized == null) {
62
+ return undefined;
63
+ }
64
+ return {
65
+ horizontalPos: serialized['horiz'] != null ? serialized['horiz'] : exports.defaultBadgePosition.horizontalPos,
66
+ verticalPos: serialized['vert'] != null ? serialized['vert'] : exports.defaultBadgePosition.verticalPos,
67
+ layer: serialized['layer'] != null ? serialized['layer'] : exports.defaultBadgePosition.layer,
68
+ responsive: serialized['responsive'] != null ? serialized['responsive'] : exports.defaultBadgePosition.responsive,
69
+ };
70
+ }
71
+ exports.deserializeBadgeEnumPosition = deserializeBadgeEnumPosition;
72
+ function serializeBadgeEnumPosition(position) {
73
+ if (position == null) {
74
+ return {
75
+ 'horiz': exports.defaultBadgePosition.horizontalPos,
76
+ 'vert': exports.defaultBadgePosition.verticalPos,
77
+ 'layer': exports.defaultBadgePosition.layer,
78
+ 'responsive': exports.defaultBadgePosition.responsive,
79
+ };
80
+ }
81
+ return {
82
+ 'horiz': position.horizontalPos,
83
+ 'vert': position.verticalPos,
84
+ 'layer': position.layer,
85
+ 'responsive': position.responsive,
86
+ };
87
+ }
88
+ exports.serializeBadgeEnumPosition = serializeBadgeEnumPosition;
89
+ function serializeBadgeEnumPositionAsKey(position) {
90
+ return JSON.stringify(position);
91
+ }
92
+ exports.serializeBadgeEnumPositionAsKey = serializeBadgeEnumPositionAsKey;
93
+ function isValidSerializedBadgeEnumPosition(val) {
94
+ // All fields are optional, so it's fine if they're not present
95
+ const horizValid = val['horiz'] == undefined || Object.values(HorizontalBadgePos).includes(val['horiz']);
96
+ const vertValid = val['vert'] == undefined || Object.values(VerticalBadgePos).includes(val['vert']);
97
+ const layerValid = val['layer'] == undefined || Object.values(BadgeLayerPos).includes(val['layer']);
98
+ const responsiveValid = val['responsive'] == undefined || Object.values(BadgeResponsiveness).includes(val['responsive']);
99
+ return horizValid && vertValid && layerValid && responsiveValid;
100
+ }
101
+ exports.isValidSerializedBadgeEnumPosition = isValidSerializedBadgeEnumPosition;
102
+ function isHorizontalPos(maybePos) {
103
+ if ((0, checks_1.isNumber)(maybePos)) {
104
+ return !!HorizontalBadgePos[maybePos];
105
+ }
106
+ return false;
107
+ }
108
+ exports.isHorizontalPos = isHorizontalPos;
109
+ function isVerticalPos(maybePos) {
110
+ if ((0, checks_1.isNumber)(maybePos)) {
111
+ return !!VerticalBadgePos[maybePos];
112
+ }
113
+ return false;
114
+ }
115
+ exports.isVerticalPos = isVerticalPos;
116
+ function isLayerPos(maybePos) {
117
+ if ((0, checks_1.isNumber)(maybePos)) {
118
+ return !!BadgeLayerPos[maybePos];
119
+ }
120
+ return false;
121
+ }
122
+ exports.isLayerPos = isLayerPos;
@@ -0,0 +1,24 @@
1
+ export declare enum DataGraphicIconSets {
2
+ CUSTOM_ICONS = -1,
3
+ STATUS_ICONS = 0,
4
+ STATUS_CIRCLES = 1,
5
+ STOPLIGHTS = 2,
6
+ TOGGLES = 3,
7
+ COMPLETION_PIES = 4,
8
+ TRENDING_ARROWS = 5,
9
+ STATUS_CHECK_BOXES = 6,
10
+ TRENDING_ARROWS_FLIPPED = 7
11
+ }
12
+ export declare type DataGraphicIconLibrarySets = Exclude<DataGraphicIconSets, DataGraphicIconSets.CUSTOM_ICONS>;
13
+ export declare type DataGraphicImage = {
14
+ url: string;
15
+ w: number;
16
+ h: number;
17
+ };
18
+ export declare type DataGraphicIconIndexes = {
19
+ set: DataGraphicIconSets;
20
+ index: number;
21
+ iconImage?: DataGraphicImage;
22
+ };
23
+ export declare function areDataGraphicIconIndexesEqual(a: DataGraphicIconIndexes, b: DataGraphicIconIndexes): boolean;
24
+ export declare function areDataGraphicImagesEqual(a: DataGraphicImage | undefined, b: DataGraphicImage | undefined): boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areDataGraphicImagesEqual = exports.areDataGraphicIconIndexesEqual = exports.DataGraphicIconSets = void 0;
4
+ var DataGraphicIconSets;
5
+ (function (DataGraphicIconSets) {
6
+ // Custom icons are a user-defined set of uploaded icons, not a predefined set of icons
7
+ DataGraphicIconSets[DataGraphicIconSets["CUSTOM_ICONS"] = -1] = "CUSTOM_ICONS";
8
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_ICONS"] = 0] = "STATUS_ICONS";
9
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_CIRCLES"] = 1] = "STATUS_CIRCLES";
10
+ DataGraphicIconSets[DataGraphicIconSets["STOPLIGHTS"] = 2] = "STOPLIGHTS";
11
+ DataGraphicIconSets[DataGraphicIconSets["TOGGLES"] = 3] = "TOGGLES";
12
+ DataGraphicIconSets[DataGraphicIconSets["COMPLETION_PIES"] = 4] = "COMPLETION_PIES";
13
+ DataGraphicIconSets[DataGraphicIconSets["TRENDING_ARROWS"] = 5] = "TRENDING_ARROWS";
14
+ DataGraphicIconSets[DataGraphicIconSets["STATUS_CHECK_BOXES"] = 6] = "STATUS_CHECK_BOXES";
15
+ DataGraphicIconSets[DataGraphicIconSets["TRENDING_ARROWS_FLIPPED"] = 7] = "TRENDING_ARROWS_FLIPPED";
16
+ })(DataGraphicIconSets = exports.DataGraphicIconSets || (exports.DataGraphicIconSets = {}));
17
+ function areDataGraphicIconIndexesEqual(a, b) {
18
+ return a.set == b.set && a.index == b.index && areDataGraphicImagesEqual(a.iconImage, b.iconImage);
19
+ }
20
+ exports.areDataGraphicIconIndexesEqual = areDataGraphicIconIndexesEqual;
21
+ function areDataGraphicImagesEqual(a, b) {
22
+ if (a == undefined || b == undefined) {
23
+ return a == b;
24
+ }
25
+ return a.w == b.w && a.h == b.h && a.url == b.url;
26
+ }
27
+ exports.areDataGraphicImagesEqual = areDataGraphicImagesEqual;
@@ -0,0 +1,15 @@
1
+ import { BadgeEnumPosition, SerializedBadgeEnumPosition } from './badgeposition';
2
+ import { DataGraphicIconIndexes } from './datagraphicindexes';
3
+ export declare type SerializedSimpleStaticDataGraphicSettings = {
4
+ 'icon': DataGraphicIconIndexes;
5
+ 'pos': SerializedBadgeEnumPosition;
6
+ 'color': string;
7
+ };
8
+ export declare type SimpleStaticDataGraphicSettings = {
9
+ icon: DataGraphicIconIndexes;
10
+ position: BadgeEnumPosition;
11
+ color: string;
12
+ };
13
+ export declare function serializeSimpleStaticDataGraphicSettings(settings: SimpleStaticDataGraphicSettings): SerializedSimpleStaticDataGraphicSettings;
14
+ export declare function deserializeSimpleStaticDataGraphicSettings(settings: SerializedSimpleStaticDataGraphicSettings): SimpleStaticDataGraphicSettings;
15
+ export declare function isSerializedSimpleStaticDataGraphicSettings(settings: unknown): settings is SerializedSimpleStaticDataGraphicSettings;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSerializedSimpleStaticDataGraphicSettings = exports.deserializeSimpleStaticDataGraphicSettings = exports.serializeSimpleStaticDataGraphicSettings = void 0;
4
+ const checks_1 = require("../../checks");
5
+ const badgeposition_1 = require("./badgeposition");
6
+ function serializeSimpleStaticDataGraphicSettings(settings) {
7
+ return {
8
+ 'icon': settings.icon,
9
+ 'pos': (0, badgeposition_1.serializeBadgeEnumPosition)(settings.position),
10
+ 'color': settings.color,
11
+ };
12
+ }
13
+ exports.serializeSimpleStaticDataGraphicSettings = serializeSimpleStaticDataGraphicSettings;
14
+ function deserializeSimpleStaticDataGraphicSettings(settings) {
15
+ return {
16
+ icon: settings['icon'],
17
+ position: (0, badgeposition_1.deserializeBadgeEnumPosition)(settings['pos']),
18
+ color: settings['color'],
19
+ };
20
+ }
21
+ exports.deserializeSimpleStaticDataGraphicSettings = deserializeSimpleStaticDataGraphicSettings;
22
+ function isSerializedSimpleStaticDataGraphicSettings(settings) {
23
+ return ((0, checks_1.isObject)(settings) &&
24
+ (0, checks_1.isString)(settings['color']) &&
25
+ (0, checks_1.isObject)(settings['icon']) &&
26
+ (0, badgeposition_1.isValidSerializedBadgeEnumPosition)(settings['pos']));
27
+ }
28
+ exports.isSerializedSimpleStaticDataGraphicSettings = isSerializedSimpleStaticDataGraphicSettings;
@@ -0,0 +1,65 @@
1
+ /** @ignore */
2
+ export declare type SerializedImageFill = {
3
+ 'pos': string;
4
+ 'url': string;
5
+ 'polys': {
6
+ 'x': number;
7
+ 'y': number;
8
+ }[][] | null;
9
+ 'w'?: number;
10
+ 'h'?: number;
11
+ 'FX'?: any[];
12
+ 'bb'?: {
13
+ 'x': number;
14
+ 'y': number;
15
+ 'w': number;
16
+ 'h': number;
17
+ };
18
+ 'location'?: string;
19
+ 'fallbackUrl'?: string;
20
+ 'rotation'?: number;
21
+ 'horizontalAlign'?: string;
22
+ 'verticalAlign'?: string;
23
+ 'FlipX'?: boolean;
24
+ 'FlipY'?: boolean;
25
+ 'isSvg'?: boolean;
26
+ };
27
+ /** @ignore */
28
+ export declare type SimpleSerializedFillStyle = string | SerializedImageFill;
29
+ /**
30
+ * Different ways of laying out the image in the background of the block.
31
+ */
32
+ export declare enum SimpleImageFillPosition {
33
+ /** The image retains its original aspect ratio, and is as large as possible while still fitting in the block */
34
+ Fit = "fit",
35
+ /** The image retains its original aspect ratio, and is as small as possible while still completely covering the block */
36
+ Fill = "fill",
37
+ /** The image is stretched to the bounding box of the block */
38
+ Stretch = "stretch",
39
+ /** The image is shown in its original size if possible */
40
+ Original = "original",
41
+ /** The image is tiled in its original size vertically and horizontally to fully cover the block */
42
+ Tile = "tile"
43
+ }
44
+ /**
45
+ * Settings for using an image as the fill style of a block.
46
+ */
47
+ export declare type SimpleImageFill = {
48
+ /**
49
+ * URL of the image to display. If a data URL is provided, the image will be uploaded
50
+ * to the current user's Lucid account and the URL replaced with a Lucid-provided one.
51
+ */
52
+ url: string;
53
+ /**
54
+ * Different ways of laying out the image in the background of the block.
55
+ */
56
+ position: SimpleImageFillPosition;
57
+ };
58
+ /**
59
+ * Settings for the fill style of a block.
60
+ *
61
+ * If a string is provided, it must be a hex color string, e.g. `'#ff00ff'` or `'#aabbcc80'`.
62
+ */
63
+ export declare type SimpleFillStyle = string | SimpleImageFill;
64
+ /** @ignore */
65
+ export declare function serializeSimpleFill(fill: SimpleFillStyle): SimpleSerializedFillStyle;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeSimpleFill = exports.SimpleImageFillPosition = void 0;
4
+ const checks_1 = require("../checks");
5
+ /**
6
+ * Different ways of laying out the image in the background of the block.
7
+ */
8
+ var SimpleImageFillPosition;
9
+ (function (SimpleImageFillPosition) {
10
+ /** The image retains its original aspect ratio, and is as large as possible while still fitting in the block */
11
+ SimpleImageFillPosition["Fit"] = "fit";
12
+ /** The image retains its original aspect ratio, and is as small as possible while still completely covering the block */
13
+ SimpleImageFillPosition["Fill"] = "fill";
14
+ /** The image is stretched to the bounding box of the block */
15
+ SimpleImageFillPosition["Stretch"] = "stretch";
16
+ /** The image is shown in its original size if possible */
17
+ SimpleImageFillPosition["Original"] = "original";
18
+ /** The image is tiled in its original size vertically and horizontally to fully cover the block */
19
+ SimpleImageFillPosition["Tile"] = "tile";
20
+ //TODO: 'mask' but mask requires additional settings
21
+ })(SimpleImageFillPosition = exports.SimpleImageFillPosition || (exports.SimpleImageFillPosition = {}));
22
+ /** @ignore */
23
+ function serializeSimpleFill(fill) {
24
+ if ((0, checks_1.isString)(fill)) {
25
+ return fill;
26
+ }
27
+ else {
28
+ return {
29
+ 'pos': fill.position,
30
+ 'url': fill.url,
31
+ 'polys': null,
32
+ };
33
+ }
34
+ }
35
+ exports.serializeSimpleFill = serializeSimpleFill;
@@ -0,0 +1,15 @@
1
+ export declare type SerializedShadow = {
2
+ 'x': number;
3
+ 'y': number;
4
+ 'b': number;
5
+ 'c': string;
6
+ 'ang'?: number;
7
+ };
8
+ export interface Shadow {
9
+ distance: number;
10
+ angle: number;
11
+ blur: number;
12
+ color: string;
13
+ }
14
+ export declare function serializeShadow(shadow: Shadow): SerializedShadow;
15
+ export declare function deserializeShadow(shadow: SerializedShadow): Shadow;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeShadow = exports.serializeShadow = void 0;
4
+ function serializeShadow(shadow) {
5
+ return {
6
+ 'x': shadow.distance * Math.cos(shadow.angle),
7
+ 'y': shadow.distance * Math.sin(shadow.angle),
8
+ 'b': shadow.blur,
9
+ 'c': shadow.color,
10
+ 'ang': shadow.angle,
11
+ };
12
+ }
13
+ exports.serializeShadow = serializeShadow;
14
+ function deserializeShadow(shadow) {
15
+ var _a;
16
+ return {
17
+ distance: Math.sqrt(shadow['x'] * shadow['x'] + shadow['y'] * shadow['y']),
18
+ angle: (_a = shadow['ang']) !== null && _a !== void 0 ? _a : Math.atan2(shadow['y'], shadow['x']),
19
+ blur: shadow['b'],
20
+ color: shadow['c'],
21
+ };
22
+ }
23
+ exports.deserializeShadow = deserializeShadow;
@@ -18,4 +18,8 @@ export declare class DataItemProxy {
18
18
  * The fields on this data item, organized by their name.
19
19
  */
20
20
  readonly fields: MapProxy<string, import("..").SerializedFieldType>;
21
+ /**
22
+ * @returns True if a data item exists in this collection at this primary key
23
+ */
24
+ exists(): boolean;
21
25
  }
@@ -24,5 +24,11 @@ class DataItemProxy {
24
24
  'f': name,
25
25
  }));
26
26
  }
27
+ /**
28
+ * @returns True if a data item exists in this collection at this primary key
29
+ */
30
+ exists() {
31
+ return this.client.sendCommand("die" /* DataItemExists */, { 'c': this.collection.id, 'pk': this.primaryKey });
32
+ }
27
33
  }
28
34
  exports.DataItemProxy = DataItemProxy;
@@ -1,4 +1,5 @@
1
1
  import { JsonObject, JsonSerializable } from '../../lucid-extension-sdk';
2
+ import { SimpleFillStyle } from '../core/properties/fillcolor';
2
3
  import { Box } from '../math';
3
4
  /**
4
5
  * The information required to create a new block on the current document
@@ -12,6 +13,14 @@ export interface BlockDefinition {
12
13
  * The initial location and size of the block on the page.
13
14
  */
14
15
  boundingBox: Box;
16
+ /**
17
+ * If specified, the initial FillColor property for the block
18
+ */
19
+ fillStyle?: SimpleFillStyle;
20
+ /**
21
+ * If specified, the initial line width for the block
22
+ */
23
+ lineWidth?: number;
15
24
  /**
16
25
  * Additional properties to set on the block immediately after creation. This is not typically
17
26
  * set directly (it's easier and safer to call `.properties.set()` after block creation) but
@@ -1,3 +1,6 @@
1
+ import { SimpleStaticDataGraphicSettings } from '../core/properties/datagraphic/staticdatagraphicsettings';
2
+ import { SimpleFillStyle } from '../core/properties/fillcolor';
3
+ import { Shadow } from '../core/properties/shadow';
1
4
  import { ItemProxy } from './itemproxy';
2
5
  /**
3
6
  * A block is a single shape on the document. A BlockProxy provides an interface to
@@ -15,10 +18,55 @@ export declare class BlockProxy extends ItemProxy {
15
18
  * @returns The amount this block is rotated around its own center, in radians.
16
19
  */
17
20
  getRotation(): number;
21
+ /**
22
+ * @param radians Angle the block should be rotated
23
+ */
24
+ setRotation(radians: number): void;
25
+ /**
26
+ * @returns The current drop shadow on this block, or undefined if no shadow is set
27
+ */
28
+ getShadow(): Shadow | undefined;
29
+ /**
30
+ * @param shadow The drop shadow to set on the block, or undefined to clear the drop shadow
31
+ */
32
+ setShadow(shadow: Shadow | undefined): void;
33
+ /**
34
+ * Set the fill style used (by most kinds of blocks) to fill in their main opaque areas.
35
+ * This can be a string color (e.g. `'#ff00ff80'`) or an image fill.
36
+ */
37
+ setFillStyle(fillStyle: SimpleFillStyle): void;
18
38
  /**
19
39
  * @returns An array of lines that have one or both endpoints connected to this block.
20
40
  */
21
41
  getConnectedLines(): import("./lineproxy").LineProxy[];
42
+ /**
43
+ * @param settings Information about the static data graphic icon to set on this block.
44
+ */
45
+ setSimpleStaticDataGraphic(settings: SimpleStaticDataGraphicSettings | undefined): void;
46
+ /**
47
+ * @returns Settings for the simple static data graphic currently set on this block, or undefined
48
+ * if no simple data graphic is currently set. Note that if a data graphic exists that is not an
49
+ * icon, this will return undefined. This function will not consider data graphics set via
50
+ * conditional formatting rules.
51
+ */
52
+ getSimpleStaticDataGraphic(): SimpleStaticDataGraphicSettings | undefined;
53
+ /**
54
+ * Lock this block's aspect ratio to its current value.
55
+ * This can be reversed with unlockAspectRatio.
56
+ */
57
+ lockAspectRatio(): void;
58
+ /**
59
+ * Unlock the aspect ratio of this block, allowing it to be stretched vertically or horizontally independently.
60
+ */
61
+ unlockAspectRatio(): void;
62
+ /**
63
+ * @returns The line width used by most kinds of blocks to render their outline.
64
+ */
65
+ getLineWidth(): number;
66
+ /**
67
+ * @param width The line width to be used (by most kinds of blocks) to render this block's outline
68
+ */
69
+ setLineWidth(width: number): void;
22
70
  /**
23
71
  * Link a text area to a data field, so that editing the text area will also update the
24
72
  * associated data, and vice versa.
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BlockProxy = void 0;
4
+ const staticdatagraphicsettings_1 = require("../core/properties/datagraphic/staticdatagraphicsettings");
5
+ const fillcolor_1 = require("../core/properties/fillcolor");
6
+ const shadow_1 = require("../core/properties/shadow");
4
7
  const itemproxy_1 = require("./itemproxy");
5
8
  /**
6
9
  * A block is a single shape on the document. A BlockProxy provides an interface to
@@ -22,6 +25,40 @@ class BlockProxy extends itemproxy_1.ItemProxy {
22
25
  getRotation() {
23
26
  return this.properties.get('Rotation');
24
27
  }
28
+ /**
29
+ * @param radians Angle the block should be rotated
30
+ */
31
+ setRotation(radians) {
32
+ this.properties.set('Rotation', radians);
33
+ }
34
+ /**
35
+ * @returns The current drop shadow on this block, or undefined if no shadow is set
36
+ */
37
+ getShadow() {
38
+ const raw = this.properties.get('Shadow');
39
+ if (!raw) {
40
+ return undefined;
41
+ }
42
+ return (0, shadow_1.deserializeShadow)(raw);
43
+ }
44
+ /**
45
+ * @param shadow The drop shadow to set on the block, or undefined to clear the drop shadow
46
+ */
47
+ setShadow(shadow) {
48
+ if (shadow) {
49
+ this.properties.set('Shadow', (0, shadow_1.serializeShadow)(shadow));
50
+ }
51
+ else {
52
+ this.properties.set('Shadow', null);
53
+ }
54
+ }
55
+ /**
56
+ * Set the fill style used (by most kinds of blocks) to fill in their main opaque areas.
57
+ * This can be a string color (e.g. `'#ff00ff80'`) or an image fill.
58
+ */
59
+ setFillStyle(fillStyle) {
60
+ this.properties.set('FillColor', (0, fillcolor_1.serializeSimpleFill)(fillStyle));
61
+ }
25
62
  /**
26
63
  * @returns An array of lines that have one or both endpoints connected to this block.
27
64
  */
@@ -29,6 +66,58 @@ class BlockProxy extends itemproxy_1.ItemProxy {
29
66
  const ids = this.client.sendCommand("gcl" /* GetConnectedLines */, this.id);
30
67
  return ids.map((id) => this.client.getLineProxy(id));
31
68
  }
69
+ /**
70
+ * @param settings Information about the static data graphic icon to set on this block.
71
+ */
72
+ setSimpleStaticDataGraphic(settings) {
73
+ if (settings) {
74
+ this.properties.set('StaticDataGraphic', (0, staticdatagraphicsettings_1.serializeSimpleStaticDataGraphicSettings)(settings));
75
+ }
76
+ else {
77
+ this.properties.set('StaticDataGraphic', undefined);
78
+ }
79
+ }
80
+ /**
81
+ * @returns Settings for the simple static data graphic currently set on this block, or undefined
82
+ * if no simple data graphic is currently set. Note that if a data graphic exists that is not an
83
+ * icon, this will return undefined. This function will not consider data graphics set via
84
+ * conditional formatting rules.
85
+ */
86
+ getSimpleStaticDataGraphic() {
87
+ const settings = this.properties.get('StaticDataGraphic');
88
+ if ((0, staticdatagraphicsettings_1.isSerializedSimpleStaticDataGraphicSettings)(settings)) {
89
+ return (0, staticdatagraphicsettings_1.deserializeSimpleStaticDataGraphicSettings)(settings);
90
+ }
91
+ else {
92
+ return undefined;
93
+ }
94
+ }
95
+ /**
96
+ * Lock this block's aspect ratio to its current value.
97
+ * This can be reversed with unlockAspectRatio.
98
+ */
99
+ lockAspectRatio() {
100
+ const bb = this.getBoundingBox();
101
+ this.properties.set('AspectRatio', bb.w / bb.h);
102
+ }
103
+ /**
104
+ * Unlock the aspect ratio of this block, allowing it to be stretched vertically or horizontally independently.
105
+ */
106
+ unlockAspectRatio() {
107
+ this.properties.set('AspectRatio', undefined);
108
+ }
109
+ /**
110
+ * @returns The line width used by most kinds of blocks to render their outline.
111
+ */
112
+ getLineWidth() {
113
+ return this.properties.get('LineWidth');
114
+ }
115
+ /**
116
+ * @param width The line width to be used (by most kinds of blocks) to render this block's outline
117
+ */
118
+ setLineWidth(width) {
119
+ this.properties.set('LineWidth', width);
120
+ }
32
121
  /**
33
122
  * Link a text area to a data field, so that editing the text area will also update the
34
123
  * associated data, and vice versa.
@@ -15,6 +15,10 @@ export declare class DocumentProxy extends ElementProxy {
15
15
  */
16
16
  readonly pages: MapProxy<string, PageProxy>;
17
17
  constructor(client: EditorClient);
18
+ /**
19
+ * An iterator over all blocks on all pages of the document
20
+ */
21
+ allBlocks(): Generator<import("./blockproxy").BlockProxy, void, unknown>;
18
22
  /**
19
23
  * Add a new page to the current document
20
24
  * @param def Definition of the page to add
@@ -18,6 +18,16 @@ class DocumentProxy extends elementproxy_1.ElementProxy {
18
18
  static getNextHookName() {
19
19
  return '__documentproxy__hook' + DocumentProxy.nextHookId++;
20
20
  }
21
+ /**
22
+ * An iterator over all blocks on all pages of the document
23
+ */
24
+ *allBlocks() {
25
+ for (const page of this.pages.values()) {
26
+ for (const block of page.blocks.values()) {
27
+ yield block;
28
+ }
29
+ }
30
+ }
21
31
  /**
22
32
  * Add a new page to the current document
23
33
  * @param def Definition of the page to add
@@ -64,6 +64,12 @@ class PageProxy extends elementproxy_1.ElementProxy {
64
64
  block.properties.set(key, def.properties[key]);
65
65
  }
66
66
  }
67
+ if (def.fillStyle !== undefined) {
68
+ block.setFillStyle(def.fillStyle);
69
+ }
70
+ if (def.lineWidth !== undefined) {
71
+ block.setLineWidth(def.lineWidth);
72
+ }
67
73
  return block;
68
74
  }
69
75
  /**
@@ -21,4 +21,9 @@ export declare class ShapeDataProxy extends WriteableMapProxy<string, Serialized
21
21
  delete(key: string): void;
22
22
  /** @ignore */
23
23
  static parseData(raw: SerializedFieldType | SerializedDataError): SerializedFieldType | DataError;
24
+ /**
25
+ * @param key Name of the shape data to read
26
+ * @returns The value if it is a string, or an empty string if it does not exist or is not a string.
27
+ */
28
+ getString(key: string): string;
24
29
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShapeDataProxy = void 0;
4
+ const checks_1 = require("../core/checks");
4
5
  const serializeddataerror_1 = require("../core/serializeddataerror");
5
6
  const shapedatainheritance_1 = require("../core/shapedatainheritance");
6
7
  const dataerror_1 = require("../data/dataerror");
@@ -53,5 +54,16 @@ class ShapeDataProxy extends mapproxy_1.WriteableMapProxy {
53
54
  //TODO, eventually: parse these
54
55
  return raw;
55
56
  }
57
+ /**
58
+ * @param key Name of the shape data to read
59
+ * @returns The value if it is a string, or an empty string if it does not exist or is not a string.
60
+ */
61
+ getString(key) {
62
+ const val = this.get(key);
63
+ if (!(0, checks_1.isString)(val)) {
64
+ return '';
65
+ }
66
+ return val;
67
+ }
56
68
  }
57
69
  exports.ShapeDataProxy = ShapeDataProxy;
@@ -0,0 +1,13 @@
1
+ import { CardIntegration } from '../core/properties/cardintegration';
2
+ import { EditorClient } from '../editorclient';
3
+ export declare class TaskManagementCardIntegration {
4
+ private readonly client;
5
+ constructor(client: EditorClient);
6
+ private static nextHookId;
7
+ private static nextHookName;
8
+ /**
9
+ * Register a new card integration.
10
+ * @param card The definition of the new card integration
11
+ */
12
+ addCardIntegration(card: CardIntegration): void;
13
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskManagementCardIntegration = void 0;
4
+ const cardintegration_1 = require("../core/properties/cardintegration");
5
+ const collectionproxy_1 = require("../data/collectionproxy");
6
+ class TaskManagementCardIntegration {
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ static nextHookName() {
11
+ return '__taskmanagementcard__hook' + TaskManagementCardIntegration.nextHookId++;
12
+ }
13
+ /**
14
+ * Register a new card integration.
15
+ * @param card The definition of the new card integration
16
+ */
17
+ addCardIntegration(card) {
18
+ const getFieldsActionName = TaskManagementCardIntegration.nextHookName();
19
+ this.client.registerAction(getFieldsActionName, async (param) => {
20
+ const collection = new collectionproxy_1.CollectionProxy(param['c'], this.client);
21
+ const fields = await card.getAllFields(collection);
22
+ const serializedFields = (0, cardintegration_1.serializeCardFieldArrayDefinition)(fields);
23
+ return serializedFields;
24
+ });
25
+ let showIntroActionName = undefined;
26
+ if (card.showIntro) {
27
+ showIntroActionName = TaskManagementCardIntegration.nextHookName();
28
+ this.client.registerAction(showIntroActionName, card.showIntro);
29
+ }
30
+ this.client.sendCommand("aci" /* AddCardIntegration */, {
31
+ 'n': card.label,
32
+ 'u': card.iconUrl,
33
+ 'gf': getFieldsActionName,
34
+ 'i': showIntroActionName,
35
+ });
36
+ }
37
+ }
38
+ exports.TaskManagementCardIntegration = TaskManagementCardIntegration;
39
+ TaskManagementCardIntegration.nextHookId = 0;
@@ -102,13 +102,14 @@ class EditorClient {
102
102
  };
103
103
  })
104
104
  .catch((error) => {
105
+ var _a, _b, _c, _d;
105
106
  const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
106
107
  throw {
107
- url: raw ? raw['url'] : '',
108
- responseText: raw ? raw['t'] : 'An unknown error occurred',
109
- status: raw ? raw['s'] : 0,
110
- headers: raw ? raw['h'] : {},
111
- timeout: raw ? raw['to'] : undefined,
108
+ url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
109
+ responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
110
+ status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
111
+ headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
112
+ timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
112
113
  };
113
114
  });
114
115
  }
@@ -131,13 +132,14 @@ class EditorClient {
131
132
  };
132
133
  })
133
134
  .catch((error) => {
134
- const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : error;
135
+ var _a, _b, _c, _d;
136
+ const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
135
137
  throw {
136
- url: raw['url'],
137
- responseText: raw['t'],
138
- status: raw['s'],
139
- headers: raw['h'],
140
- timeout: raw['to'],
138
+ url: (_a = raw === null || raw === void 0 ? void 0 : raw['url']) !== null && _a !== void 0 ? _a : '',
139
+ responseText: (_b = raw === null || raw === void 0 ? void 0 : raw['t']) !== null && _b !== void 0 ? _b : 'An unknown error occurred',
140
+ status: (_c = raw === null || raw === void 0 ? void 0 : raw['s']) !== null && _c !== void 0 ? _c : 0,
141
+ headers: (_d = raw === null || raw === void 0 ? void 0 : raw['h']) !== null && _d !== void 0 ? _d : {},
142
+ timeout: raw === null || raw === void 0 ? void 0 : raw['to'],
141
143
  };
142
144
  });
143
145
  }
package/sdk/ui/panel.d.ts CHANGED
@@ -5,7 +5,9 @@ import { IframeUI } from './iframeui';
5
5
  */
6
6
  export declare enum PanelLocation {
7
7
  /** In Lucidchart, create a sibling to the Contextual Panel */
8
- RightDock = 1
8
+ RightDock = 1,
9
+ /** In Lucidchart, create a sibling to the shape toolbox */
10
+ ContentDock = 2
9
11
  }
10
12
  export interface PanelConfig {
11
13
  /** Title to display at the top of the panel */
package/sdk/ui/panel.js CHANGED
@@ -9,6 +9,8 @@ var PanelLocation;
9
9
  (function (PanelLocation) {
10
10
  /** In Lucidchart, create a sibling to the Contextual Panel */
11
11
  PanelLocation[PanelLocation["RightDock"] = 1] = "RightDock";
12
+ /** In Lucidchart, create a sibling to the shape toolbox */
13
+ PanelLocation[PanelLocation["ContentDock"] = 2] = "ContentDock";
12
14
  })(PanelLocation = exports.PanelLocation || (exports.PanelLocation = {}));
13
15
  /**
14
16
  * Extend this class to show a custom panel to the user, whose contents are displayed in a sandboxed
@@ -1,3 +1,4 @@
1
+ import { BlockDefinition } from '../../lucid-extension-sdk';
1
2
  import { ItemProxy } from '../document/itemproxy';
2
3
  import { PageProxy } from '../document/pageproxy';
3
4
  import { EditorClient } from '../editorclient';
@@ -69,4 +70,19 @@ export declare class Viewport {
69
70
  * @param handle The return value of hookSelection.
70
71
  */
71
72
  unhookSelection(handle: string): void;
73
+ /**
74
+ * Start an interaction of the current user dragging a new block onto the current page, exactly
75
+ * as if they started dragging that block out of the normal toolbox. At the time this function is
76
+ * called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
77
+ *
78
+ * @param definition Definition of the block to create if and where the user drops it on-canvas
79
+ * @returns A promise resolving to a reference to the created block, if successfully dropped,
80
+ * or undefined if the user cancels the drag interaction.
81
+ */
82
+ startDraggingNewBlock(definition: BlockDefinition): Promise<import("../document/blockproxy").BlockProxy | undefined>;
83
+ /**
84
+ * If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
85
+ * cancel that interaction.
86
+ */
87
+ cancelDraggingNewBlock(): void;
72
88
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Viewport = void 0;
4
4
  const checks_1 = require("../core/checks");
5
+ const fillcolor_1 = require("../core/properties/fillcolor");
5
6
  const itemproxy_1 = require("../document/itemproxy");
6
7
  const pageproxy_1 = require("../document/pageproxy");
7
8
  const math_1 = require("../math");
@@ -126,6 +127,42 @@ class Viewport {
126
127
  this.client.deleteAction(handle);
127
128
  this.client.sendCommand("us" /* UnhookSelection */, { 'n': handle });
128
129
  }
130
+ /**
131
+ * Start an interaction of the current user dragging a new block onto the current page, exactly
132
+ * as if they started dragging that block out of the normal toolbox. At the time this function is
133
+ * called, the user's primary mouse button should be down (e.g. in a mousedown event handler).
134
+ *
135
+ * @param definition Definition of the block to create if and where the user drops it on-canvas
136
+ * @returns A promise resolving to a reference to the created block, if successfully dropped,
137
+ * or undefined if the user cancels the drag interaction.
138
+ */
139
+ async startDraggingNewBlock(definition) {
140
+ var _a;
141
+ const properties = (_a = definition.properties) !== null && _a !== void 0 ? _a : {};
142
+ if (definition.fillStyle !== undefined) {
143
+ properties['FillColor'] = (0, fillcolor_1.serializeSimpleFill)(definition.fillStyle);
144
+ }
145
+ if (definition.lineWidth !== undefined) {
146
+ properties['LineWidth'] = definition.lineWidth;
147
+ }
148
+ const maybeBlockId = await this.client.sendCommand("sdc" /* StartDragBlockToCanvas */, {
149
+ 'c': definition.className,
150
+ 'sz': {
151
+ 'w': definition.boundingBox.w,
152
+ 'h': definition.boundingBox.h,
153
+ },
154
+ 'p': properties,
155
+ 's': definition.stencil,
156
+ });
157
+ return maybeBlockId ? this.client.getBlockProxy(maybeBlockId) : undefined;
158
+ }
159
+ /**
160
+ * If startDraggingNewBlock has been called, and the drag-new-block interaction is still active,
161
+ * cancel that interaction.
162
+ */
163
+ cancelDraggingNewBlock() {
164
+ this.client.sendCommand("cdc" /* CancelDragBlockToCanvas */, undefined);
165
+ }
129
166
  }
130
167
  exports.Viewport = Viewport;
131
168
  Viewport.nextHookId = 0;