@sheetxl/sdk 0.8.0-beta.4 → 0.8.0-beta.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.
Files changed (110) hide show
  1. package/browser/cjs/-wfVn4ubg563jjqj.cjs +93 -0
  2. package/browser/cjs/B2GVAGA-CBeu_7U4.cjs +1 -0
  3. package/browser/cjs/{B5eE9jdzHkM8tFuQ.cjs → CMrcyRRWS0gjwpr2.cjs} +1 -1
  4. package/browser/cjs/{BNeaA3zuOokpev3O.cjs → DFKGFVvoELb8_p_B.cjs} +1 -1
  5. package/browser/cjs/{CJK0UKBYYLMe5y7n.cjs → KMBs7XyoINajcR-L.cjs} +1 -1
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{CcB0KWKqtNYkSb4T.mjs → 7_M82_Otn5kHQ0qd.mjs} +2 -2
  8. package/browser/esm/{CrLATXO_z7wtfQdU.mjs → CEk-nufZXNFx5jDl.mjs} +9498 -8365
  9. package/browser/esm/{Cbmh2jP9H2-gYBQM.mjs → CfoNUsKHL7SzfO8c.mjs} +2 -2
  10. package/browser/esm/{CLNdkRPXU9Vs9_D0.mjs → DBjWjEUK9qrHG5VD.mjs} +1 -1
  11. package/browser/esm/{Bo_UXn6gOo4WtFaK.mjs → DRsp6JAObqXYGvhz.mjs} +2 -2
  12. package/browser/esm/{CCiusSzUCYBTSrjh.mjs → J1egfq2ajlXPw3Ki.mjs} +2 -2
  13. package/browser/esm/{RKmI4uT6cEURNbC6.mjs → iLZfKwfSx5bQgCOp.mjs} +2 -2
  14. package/browser/esm/index.mjs +8 -8
  15. package/node/esm/{BUD7-kF0NUZGvJ71.mjs → BMtLBfP7JzIsG9_G.mjs} +1 -1
  16. package/node/esm/{B5aWdYZUUJ3I1yku.mjs → CynxiHhVY9UGe_h6.mjs} +1 -1
  17. package/node/esm/{DnPPf2PdWs2Hcaau.mjs → DYRjFZ75QYgmgEWF.mjs} +1 -1
  18. package/node/esm/{CXZXQq46kIHcA26q.mjs → DpyQm1VnGyCmRRKJ.mjs} +1 -1
  19. package/node/esm/index.mjs +12695 -11554
  20. package/package.json +6 -6
  21. package/resources/locales/de/model.msg.json +16 -0
  22. package/resources/locales/en/model.msg.json +16 -0
  23. package/types/scripting-api.json +6166 -6120
  24. package/types/scripting.d.ts +481 -128
  25. package/types/src/calculation/_TableRename.d.ts +13 -0
  26. package/types/src/calculation/grid/CalcGrid.d.ts +18 -3
  27. package/types/src/calculation/grid/CalcGridBackend.d.ts +49 -0
  28. package/types/src/calculation/grid/CalcGridProxy.d.ts +5 -0
  29. package/types/src/calculation/grid/ICalcGrid.d.ts +37 -0
  30. package/types/src/calculation/grid/_CalcRequest.d.ts +22 -0
  31. package/types/src/calculation/state/CalculationContext.d.ts +7 -1
  32. package/types/src/cell/ICell.d.ts +21 -1
  33. package/types/src/chart/Chart.d.ts +5 -18
  34. package/types/src/chart/ChartCollection.d.ts +1 -1
  35. package/types/src/chart/IChart.d.ts +11 -10
  36. package/types/src/chart/IChartCollection.d.ts +3 -3
  37. package/types/src/color/_BuiltInIndexDefs.d.ts +6 -0
  38. package/types/src/comment/Comment.d.ts +69 -7
  39. package/types/src/comment/IComment.d.ts +70 -51
  40. package/types/src/comment/NoteMovable.d.ts +26 -0
  41. package/types/src/comment/_CommentUtils.d.ts +23 -1
  42. package/types/src/comment/_NoteBox.d.ts +50 -0
  43. package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +27 -2
  44. package/types/src/condition/BuiltInOperators/AfterEqualToOperator.d.ts +2 -0
  45. package/types/src/condition/BuiltInOperators/AfterOperator.d.ts +2 -0
  46. package/types/src/condition/BuiltInOperators/AndOperator.d.ts +3 -1
  47. package/types/src/condition/BuiltInOperators/AverageOperator.d.ts +2 -0
  48. package/types/src/condition/BuiltInOperators/BeforeEqualToOperator.d.ts +2 -0
  49. package/types/src/condition/BuiltInOperators/BeforeOperator.d.ts +2 -0
  50. package/types/src/condition/BuiltInOperators/BetweenOperator.d.ts +2 -0
  51. package/types/src/condition/BuiltInOperators/ContainsOperator.d.ts +2 -0
  52. package/types/src/condition/BuiltInOperators/EndsWithOperator.d.ts +2 -0
  53. package/types/src/condition/BuiltInOperators/EqualToOperator.d.ts +2 -0
  54. package/types/src/condition/BuiltInOperators/ExpressionOperator.d.ts +2 -0
  55. package/types/src/condition/BuiltInOperators/GreaterThanEqualToOperator.d.ts +2 -0
  56. package/types/src/condition/BuiltInOperators/GreaterThanOperator.d.ts +2 -0
  57. package/types/src/condition/BuiltInOperators/InSetOperator.d.ts +2 -0
  58. package/types/src/condition/BuiltInOperators/LessThanEqualToOperator.d.ts +2 -0
  59. package/types/src/condition/BuiltInOperators/LessThanOperator.d.ts +2 -0
  60. package/types/src/condition/BuiltInOperators/NotOperator.d.ts +2 -0
  61. package/types/src/condition/BuiltInOperators/OrOperator.d.ts +3 -1
  62. package/types/src/condition/BuiltInOperators/StartsWithOperator.d.ts +2 -0
  63. package/types/src/condition/BuiltInOperators/TimePeriodOperator.d.ts +2 -0
  64. package/types/src/condition/BuiltInOperators/TopNOperator.d.ts +6 -0
  65. package/types/src/condition/Condition.d.ts +2 -0
  66. package/types/src/condition/ICondition.d.ts +59 -2
  67. package/types/src/condition/_ConditionUtils.d.ts +10 -0
  68. package/types/src/filter/IFilter.d.ts +76 -1
  69. package/types/src/license/license-key.d.ts +2 -2
  70. package/types/src/movable/AbstractMovableContent.d.ts +54 -0
  71. package/types/src/movable/Control.d.ts +5 -7
  72. package/types/src/movable/CustomElement.d.ts +4 -5
  73. package/types/src/movable/IControl.d.ts +7 -5
  74. package/types/src/movable/ICustomElement.d.ts +7 -2
  75. package/types/src/movable/IMovable.d.ts +74 -42
  76. package/types/src/movable/IMovableCollection.d.ts +6 -0
  77. package/types/src/movable/Movable.d.ts +53 -32
  78. package/types/src/numFmt/_FormatCell.d.ts +9 -0
  79. package/types/src/person/index.d.ts +1 -0
  80. package/types/src/picture/IPicture.d.ts +7 -1
  81. package/types/src/picture/Picture.d.ts +5 -4
  82. package/types/src/primitives/Range.d.ts +31 -1
  83. package/types/src/primitives/RangeStats.d.ts +7 -2
  84. package/types/src/primitives/ReferenceRange.d.ts +2 -0
  85. package/types/src/primitives/stats/AggregateStats.d.ts +49 -15
  86. package/types/src/primitives/stats/FrequencyStats.d.ts +1 -1
  87. package/types/src/primitives/stats/Ranked.d.ts +1 -1
  88. package/types/src/primitives/stats/SortedNumbers.d.ts +2 -2
  89. package/types/src/shape/IShape.d.ts +6 -4
  90. package/types/src/shape/Shape.d.ts +5 -10
  91. package/types/src/sheet/ISheet.d.ts +3 -2
  92. package/types/src/sheet/Sheet.d.ts +73 -21
  93. package/types/src/sheet/SheetCell.d.ts +1 -1
  94. package/types/src/sheet/_SheetFilterUtils.d.ts +17 -0
  95. package/types/src/sheet/_SheetStateTypes.d.ts +18 -0
  96. package/types/src/sheet/_SheetUtils.d.ts +15 -0
  97. package/types/src/sheetHeader/ISheetHeader.d.ts +17 -0
  98. package/types/src/sheetHeader/SheetHeader.d.ts +11 -0
  99. package/types/src/slicer/ISlicer.d.ts +7 -2
  100. package/types/src/slicer/Slicer.d.ts +5 -9
  101. package/types/src/table/AnchoredTable.d.ts +46 -6
  102. package/types/src/table/ITable.d.ts +10 -1
  103. package/types/src/table/ITableCollection.d.ts +10 -0
  104. package/types/src/table/_FilterField.d.ts +9 -1
  105. package/types/src/text/richtext/IRichText.d.ts +36 -0
  106. package/types/src/text/richtext/index.d.ts +1 -0
  107. package/types/src/transaction/ITransaction.d.ts +11 -0
  108. package/types/src/transaction/Transaction.d.ts +2 -0
  109. package/browser/cjs/Bjifbb6rRolOGtDI.cjs +0 -1
  110. package/browser/cjs/BuqhBOLW4GUYwVXx.cjs +0 -93
@@ -61,6 +61,18 @@ export interface ICondition<P = any> {
61
61
  * - Hide for ConditionalFormat/TableFilter (default behavior is usually correct)
62
62
  */
63
63
  isIncludeBlanks(): boolean;
64
+ /**
65
+ * Whether the condition can be authored as it is.
66
+ *
67
+ * @returns A message key naming the first problem — an operand not yet given, bounds the wrong
68
+ * way around, a whole-number rule holding a fraction — or `null` when there is none.
69
+ *
70
+ * @remarks
71
+ * Advisory, and what an editor asks before it saves: the rules are the ones Excel's dialogs
72
+ * refuse on. A condition read from a file is kept and evaluated whatever this answers; a
73
+ * comparison missing an operand evaluates as inert rather than as wrong.
74
+ */
75
+ validate(): string | null;
64
76
  /**
65
77
  * Returns a string representation of the selector, operator, and param.
66
78
  */
@@ -311,16 +323,22 @@ export declare namespace ICondition {
311
323
  * @remarks
312
324
  * A formula is authored as a `=`-prefixed string or an {@link ICalculation.IFormula}; a resolved
313
325
  * condition holds it as an `IFormula`.
326
+ *
327
+ * `null` while not yet given. The comparison matches nothing, and excludes nothing, until both
328
+ * bounds are.
314
329
  */
315
- from: number | string | ICalculation.IFormula;
330
+ from: number | string | ICalculation.IFormula | null;
316
331
  /**
317
332
  * The upper bound value — a number, or a formula whose result is compared per cell.
318
333
  *
319
334
  * @remarks
320
335
  * A formula is authored as a `=`-prefixed string or an {@link ICalculation.IFormula}; a resolved
321
336
  * condition holds it as an `IFormula`.
337
+ *
338
+ * `null` while not yet given. The comparison matches nothing, and excludes nothing, until both
339
+ * bounds are.
322
340
  */
323
- to: number | string | ICalculation.IFormula;
341
+ to: number | string | ICalculation.IFormula | null;
324
342
  }
325
343
  interface ColorOption {
326
344
  /**
@@ -539,6 +557,18 @@ export declare namespace ICondition {
539
557
  * Convert the value to the specified scalar type.
540
558
  */
541
559
  toType<T extends InteropScalar>(value: Scalar, type: InteropScalarType): T;
560
+ /**
561
+ * The text the current cell shows, when the evaluation matches by text; `null` otherwise.
562
+ *
563
+ * @remarks
564
+ * A filter matches by shown text unless asked not to ({@link ICondition.RangeOptions.match}):
565
+ * a cell holding `1.5` and showing `1.50` is the item `1.50`. Conditional formats and data
566
+ * validations match by value, so this answers `null` for them. An operator that compares
567
+ * text reads `ctx.getText() ?? value`.
568
+ *
569
+ * Formatted on demand, so an operator that never asks pays nothing.
570
+ */
571
+ getText(): string | null;
542
572
  /**
543
573
  * Resolves a condition input to a fully-built ICondition instance.
544
574
  *
@@ -717,6 +747,13 @@ export declare namespace ICondition {
717
747
  * Creates the default param for this operator type.
718
748
  */
719
749
  createDefaultParam?(lhsSelector?: ICondition.ISelector): P | null | undefined;
750
+ /**
751
+ * Whether `param` is one this operator can be authored with under `lhsSelector`.
752
+ *
753
+ * @returns A message key naming the first problem, or `null` when there is none. Omitted, any
754
+ * param is taken. See {@link ICondition.validate}.
755
+ */
756
+ validateParam?(param: P, lhsSelector?: ICondition.ISelector | null): string | null;
720
757
  /**
721
758
  * Returns a human-readable title of the operator.
722
759
  */
@@ -958,6 +995,26 @@ export declare namespace ICondition {
958
995
  * with no explicit `hasHeader` evaluates the entire range, header row included.
959
996
  */
960
997
  hasHeader?: boolean;
998
+ /**
999
+ * What a filter's list items and `equalTo` text are compared with: the text a cell shows, or
1000
+ * the value it holds.
1001
+ *
1002
+ * @defaultValue `'text'`
1003
+ *
1004
+ * @remarks
1005
+ * `'text'` is a spreadsheet's AutoFilter: the item `1.50` keeps a cell holding `1.5` under the
1006
+ * format `0.00`, and the item `1.5` does not. A number passed as an item or operand still
1007
+ * matches the cells holding that number, however they are formatted.
1008
+ *
1009
+ * `'value'` compares typed values only, so the text `"1"` never matches the number `1`.
1010
+ *
1011
+ * Comparisons (`>`, `between`), Top N, averages, date periods and date groups read the value
1012
+ * either way, and the text operators (contains, starts with, ends with) only ever match a
1013
+ * cell that holds text.
1014
+ *
1015
+ * Read by filters. Conditional formats and data validations match by value.
1016
+ */
1017
+ match?: 'text' | 'value';
961
1018
  }
962
1019
  /**
963
1020
  * JSON for serialization and round-tripping.
@@ -26,6 +26,8 @@ export declare class ConditionOperator<P = any> implements ICondition.IOperator<
26
26
  getDescription(): string | null;
27
27
  /** {@inheritDoc ICondition.createDefaultParam} */
28
28
  createDefaultParam(lhsSelector?: ICondition.ISelector): P | null | undefined;
29
+ /** {@inheritDoc ICondition.IOperator.validateParam} */
30
+ validateParam(param: P, lhsSelector?: ICondition.ISelector | null): string | null;
29
31
  /** {@inheritDoc ICondition.doBatch} */
30
32
  doBatch(keys: Set<any>, param: P, ctx: ICondition.IContext): MaybePromise<IRange<boolean> | null> | undefined;
31
33
  /** {@inheritDoc ICondition.toString} */
@@ -124,6 +126,8 @@ export declare class UnresolvedCondition<P = any> implements ICondition<P> {
124
126
  getParam(): P;
125
127
  /** {@inheritDoc ICondition.isIncludeBlanks} */
126
128
  isIncludeBlanks(): boolean;
129
+ /** {@inheritDoc ICondition.validate} */
130
+ validate(): string | null;
127
131
  /** {@inheritDoc ICondition.toString} */
128
132
  toString(): string;
129
133
  /** {@inheritDoc ICondition.toJSON} */
@@ -174,6 +178,12 @@ export interface DoRunRangeConditionsOptions extends ICondition.RangeOptions {
174
178
  values: ISparseGrid<Scalar>;
175
179
  coords: Readonly<IRange.Coords>;
176
180
  getHiddenRuns?: (axis: IRange.Axis) => readonly RunCoords[];
181
+ /**
182
+ * The text a cell shows, backing {@link ICondition.IContext.getText}. Supplied by the sheet;
183
+ * asked only when {@link ICondition.RangeOptions.match} is not `'value'`, and only for the
184
+ * cells a text-comparing operator reads. `value` is the cell's, which the driver holds already.
185
+ */
186
+ getText?: (rowIndex: number, colIndex: number, value: Scalar) => string;
177
187
  /**
178
188
  * Called once per contiguous run of rows/columns (per {@link ICondition.RangeOptions.axis})
179
189
  * that remain visible once every condition has been applied, in ascending order.
@@ -1,4 +1,4 @@
1
- import { IRange } from '@sheetxl/primitives';
1
+ import { IRange, Scalar } from '@sheetxl/primitives';
2
2
  import { ITransaction } from '../transaction';
3
3
  import { ICondition } from '../condition';
4
4
  import { ICellRange } from '../cellRange';
@@ -46,6 +46,36 @@ export interface IFilter extends ICondition.Stateful, IFilter.IFilterable {
46
46
  * This is relative to the table.
47
47
  */
48
48
  getIndex(): number;
49
+ /**
50
+ * The column's distinct values, as a filter menu lists them.
51
+ *
52
+ * @param options See {@link IFilter.GetItemsOptions}.
53
+ *
54
+ * @remarks
55
+ * Which rows are read depends on the column:
56
+ * - With no condition on it, the rows that are showing. A row hidden by another column's filter,
57
+ * or by hand, is not listed.
58
+ * - With a condition on it, the rows every *other* column's filter passes, so a value this
59
+ * column's own condition hides is listed too, unchecked.
60
+ *
61
+ * An item is `checked` when at least one row holding it passes the filters, so a column filtered
62
+ * by any condition (`> 5`, say) lists the passing values checked. A row hidden by hand does not
63
+ * uncheck its value.
64
+ *
65
+ * Reads the stored values in one pass; the cost follows the column's content, not its extent.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const filter = table.getColumnAt(1).getFilter();
70
+ * const { items } = await filter.getItems();
71
+ * // keep the first two values
72
+ * await filter.setCondition({
73
+ * operator: ICondition.BuiltInOperatorNames.InSet,
74
+ * param: { items: items.slice(0, 2).map((item) => item.text) }
75
+ * });
76
+ * ```
77
+ */
78
+ getItems(options?: IFilter.GetItemsOptions): Promise<IFilter.Items>;
49
79
  /** For runtime type checking. */
50
80
  readonly isIFilter: true;
51
81
  }
@@ -61,6 +91,51 @@ export declare namespace IFilter {
61
91
  conditions?: ICondition.JSON[];
62
92
  axis?: IRange.Axis;
63
93
  }
94
+ /**
95
+ * Options for {@link IFilter.getItems}.
96
+ */
97
+ interface GetItemsOptions {
98
+ /**
99
+ * The distinct values to stop at.
100
+ *
101
+ * @defaultValue `10000`
102
+ */
103
+ limit?: number;
104
+ }
105
+ /**
106
+ * One distinct value of a filtered column.
107
+ */
108
+ interface Item {
109
+ /**
110
+ * The text the cells show. This is the item an `InSet` condition holds: a filter matches by
111
+ * shown text ({@link ICondition.RangeOptions.match}).
112
+ */
113
+ text: string;
114
+ /** The value of the first cell showing `text`; the item's place in the order. */
115
+ value: Scalar;
116
+ /** The rows holding the value. */
117
+ count: number;
118
+ /** Whether at least one row holding the value passes the filters. */
119
+ checked: boolean;
120
+ }
121
+ /**
122
+ * What {@link IFilter.getItems} answers.
123
+ */
124
+ interface Items {
125
+ /**
126
+ * The distinct texts, ascending by the workbook's comparison of their values. Values that
127
+ * show alike are one item. Blanks are not an item.
128
+ */
129
+ items: readonly Item[];
130
+ /** Whether a listed row is blank. */
131
+ hasBlanks: boolean;
132
+ /** Whether at least one blank row passes the filters. */
133
+ blanksChecked: boolean;
134
+ /** Whether the column has more distinct values than `limit`; the rest are not listed. */
135
+ truncated: boolean;
136
+ /** The rows read. */
137
+ total: number;
138
+ }
64
139
  /**
65
140
  * Interface indicating the ability to filter data.
66
141
  */
@@ -31,7 +31,7 @@ export interface LicenseAndKey {
31
31
  }
32
32
  export interface LicenseKeyDetails {
33
33
  licensee: string;
34
- type?: string;
34
+ type?: string | null;
35
35
  expiration?: string | null;
36
36
  developerCount?: number;
37
37
  /**
@@ -40,7 +40,7 @@ export interface LicenseKeyDetails {
40
40
  */
41
41
  runtimes?: LicenseRuntime[] | null;
42
42
  /** Licensed origins, `<protocol>://<host>` each (see `Origin`); a string is comma-separated. */
43
- domains?: string | string[];
43
+ domains?: string | string[] | null;
44
44
  fingerprint?: string | null;
45
45
  cpuCount?: number | null;
46
46
  memory?: number | null;
@@ -0,0 +1,54 @@
1
+ import { AbstractModel, IModel } from '../model';
2
+ import { IMovable } from './IMovable';
3
+ /**
4
+ * What every content shares: its name, its description and the movable that places it.
5
+ */
6
+ export declare abstract class AbstractMovableContent<STATE extends AbstractMovableContent.State = AbstractMovableContent.State, JSON extends any = any, EVENTS extends IModel.Events = IModel.Events> extends AbstractModel<STATE, JSON, EVENTS> implements IMovable.IContent {
7
+ /** Numbers the default names: `Chart 3`. */
8
+ static instanceCounter: number;
9
+ private _getMovable;
10
+ constructor(options: AbstractMovableContent.ConstructorOptions<JSON>);
11
+ /** {@inheritDoc IMovable.IContent.getTypeDescription} */
12
+ abstract getTypeDescription(): string;
13
+ /** {@inheritDoc IMovable.IContent.getName} */
14
+ getName(): string | null;
15
+ /** {@inheritDoc IMovable.IContent.setName} */
16
+ setName(name: string): this;
17
+ /** {@inheritDoc IMovable.IContent.getDescription} */
18
+ getDescription(): string | null;
19
+ /** {@inheritDoc IMovable.IContent.setDescription} */
20
+ setDescription(description: string | null): this;
21
+ /** {@inheritDoc IMovable.IContent.getMovable} */
22
+ getMovable(): IMovable | null;
23
+ /** @internal */
24
+ protected _protectionCheck(description: string): void;
25
+ }
26
+ /**
27
+ * Interfaces for creating movable content.
28
+ *
29
+ * @see
30
+ * ### **Interface**
31
+ *
32
+ * {@link AbstractMovableContent}
33
+ */
34
+ export declare namespace AbstractMovableContent {
35
+ interface State extends AbstractModel.State {
36
+ name?: string | null;
37
+ description?: string | null;
38
+ }
39
+ interface ConstructorOptions<J> extends IModel.ConstructorOptions<J> {
40
+ /**
41
+ * The name. Content that a movable places is given one when this is empty.
42
+ */
43
+ name?: string | null;
44
+ /**
45
+ * The alternative text.
46
+ */
47
+ description?: string | null;
48
+ /**
49
+ * Returns the movable that places the content. Not provided for content that has none.
50
+ */
51
+ getMovable?: () => IMovable | null;
52
+ }
53
+ }
54
+ //# sourceMappingURL=AbstractMovableContent.d.ts.map
@@ -1,14 +1,14 @@
1
1
  import { IResource, IResourceCollection } from '../resource';
2
- import { IModel, AbstractModel } from '../model';
3
2
  import { IEmbeddedPart } from '../io';
4
3
  import { IControl } from './IControl';
5
- interface State extends AbstractModel.State {
4
+ import { AbstractMovableContent } from './AbstractMovableContent';
5
+ interface State extends AbstractMovableContent.State {
6
6
  data?: IControl.JSON;
7
7
  }
8
8
  /**
9
9
  * Implementation for {@link IControl}.
10
10
  */
11
- export declare class Control extends AbstractModel<State, IControl.JSON> implements IControl {
11
+ export declare class Control extends AbstractMovableContent<State, IControl.JSON> implements IControl {
12
12
  /**
13
13
  * The part describing the control. Held beside {@link State.data} rather than in it because the
14
14
  * resources it may carry are model references, not JSON, and have to be re-persisted per save.
@@ -21,11 +21,9 @@ export declare class Control extends AbstractModel<State, IControl.JSON> impleme
21
21
  getShapeId(): number | null;
22
22
  /** {@inheritDoc IControl.getXML} */
23
23
  getXML(): string | null;
24
- /** {@inheritDoc Movable.Content.getDescription} */
25
- getDescription(): string;
26
24
  /** {@inheritDoc Movable.Content.toJSON} */
27
25
  toJSON(toResourceId?: (resource: IResource) => number | null): IControl.JSON | null;
28
- /** {@inheritDoc Movable.Content.getTypeDescription} */
26
+ /** {@inheritDoc IMovable.IContent.getTypeDescription} */
29
27
  getTypeDescription(): string;
30
28
  /** {@inheritDoc IControl.isIControl} */
31
29
  get isIControl(): true;
@@ -42,7 +40,7 @@ export declare namespace Control {
42
40
  /**
43
41
  * Options for creating a Control.
44
42
  */
45
- interface ConstructorOptions extends IModel.ConstructorOptions<IControl.JSON> {
43
+ interface ConstructorOptions extends AbstractMovableContent.ConstructorOptions<IControl.JSON> {
46
44
  /**
47
45
  * Returns an IResource from the resourceId or null if not found.
48
46
  */
@@ -1,17 +1,16 @@
1
1
  import { IResource, IResourceCollection } from '../resource';
2
- import { IModel, AbstractModel } from '../model';
3
2
  import { ICustomElement } from './ICustomElement';
4
- interface State extends AbstractModel.State {
3
+ import { AbstractMovableContent } from './AbstractMovableContent';
4
+ interface State extends AbstractMovableContent.State {
5
5
  data?: any;
6
6
  type: string;
7
7
  }
8
8
  /**
9
9
  * Implementation for {@link ICustomElement}.
10
10
  */
11
- export declare class CustomElement extends AbstractModel<State, ICustomElement.JSON> implements ICustomElement {
11
+ export declare class CustomElement extends AbstractMovableContent<State, ICustomElement.JSON> implements ICustomElement {
12
12
  constructor(options: CustomElement.ConstructorOptions);
13
13
  getType(): string;
14
- getDescription(): string;
15
14
  toJSON(_toResourceId?: (resource: IResource) => number | null): ICustomElement.JSON | null;
16
15
  getTypeDescription(): string;
17
16
  }
@@ -27,7 +26,7 @@ export declare namespace CustomElement {
27
26
  /**
28
27
  * Options for creating a Custom Element.
29
28
  */
30
- interface ConstructorOptions extends IModel.ConstructorOptions<ICustomElement.JSON> {
29
+ interface ConstructorOptions extends AbstractMovableContent.ConstructorOptions<ICustomElement.JSON> {
31
30
  /**
32
31
  * Returns an IResource from the resourceId or null if not found.
33
32
  */
@@ -1,17 +1,15 @@
1
1
  import { IListener } from '../listener';
2
+ import { ITransaction } from '../transaction';
2
3
  import { IResource } from '../resource';
3
4
  import { IModel } from '../model';
4
5
  import { IEmbeddedPart } from '../io';
6
+ import { IMovable } from './IMovable';
5
7
  /**
6
8
  * Interface for working with form controls — a button, a checkbox, a scrollbar placed on a sheet.
7
9
  *
8
10
  * **PLACEHOLDER** - This is under development and not made public yet.
9
11
  */
10
- export interface IControl extends IModel {
11
- /**
12
- * Returns a description for assistive technologies.
13
- */
14
- getDescription(): string;
12
+ export interface IControl extends IModel, IMovable.IContent {
15
13
  /**
16
14
  * Returns the id of the shape that draws this control, or `null` if it has none.
17
15
  *
@@ -31,6 +29,10 @@ export interface IControl extends IModel {
31
29
  */
32
30
  getXML(): string | null;
33
31
  toJSON(toResourceId?: (resource: IResource) => number | null): IControl.JSON | null;
32
+ /**
33
+ * Deletes the control, and with it the movable that places it.
34
+ */
35
+ delete(options?: ITransaction.OperationOptions): void;
34
36
  /** For runtime type checking. */
35
37
  readonly isIControl: true;
36
38
  }
@@ -1,14 +1,19 @@
1
1
  import { IListener } from '../listener';
2
+ import { ITransaction } from '../transaction';
2
3
  import { IResource } from '../resource';
3
4
  import { IModel } from '../model';
5
+ import { IMovable } from './IMovable';
4
6
  /**
5
7
  * Interface for working with CustomMovables.
6
8
 
7
9
  * **PLACEHOLDER**
8
10
  */
9
- export interface ICustomElement extends IModel {
11
+ export interface ICustomElement extends IModel, IMovable.IContent {
10
12
  toJSON(toResourceId?: (resource: IResource) => number | null): ICustomElement.JSON | null;
11
- getDescription(): string;
13
+ /**
14
+ * Deletes the element, and with it the movable that places it.
15
+ */
16
+ delete(options?: ITransaction.OperationOptions): void;
12
17
  }
13
18
  /**
14
19
  * {@inheritDoc ICustomElement}
@@ -3,7 +3,6 @@ import { ITypes } from '../type';
3
3
  import { ITransaction } from '../transaction';
4
4
  import { IResource } from '../resource';
5
5
  import { IListener } from '../listener';
6
- import { IModel } from '../model';
7
6
  import { ICellRange } from '../cellRange';
8
7
  import { IHistory } from '../history';
9
8
  import { IAnchored } from '../anchored';
@@ -43,7 +42,10 @@ export interface IMovable extends IAnchored, ITransaction.ITransactional, IHisto
43
42
  * | `'control'` | {@link IControl} — a form control |
44
43
  *
45
44
  * Anything else is content that is positioned and saved but not modeled; it answers
46
- * `getType()` and nothing more.
45
+ * {@link IMovable.IContent} and nothing more.
46
+ *
47
+ * The content owns what identifies it: its name, its description and its id. The movable owns
48
+ * where it is drawn. To remove both, delete the content.
47
49
  *
48
50
  * @example
49
51
  * ```ts
@@ -51,9 +53,14 @@ export interface IMovable extends IAnchored, ITransaction.ITransactional, IHisto
51
53
  * if (content.getType() === 'shape') {
52
54
  * const text = (content as IShape).getTextFrame()?.getText();
53
55
  * }
56
+ * content.delete();
54
57
  * ```
55
58
  */
56
- getContent<T extends IModel>(): T;
59
+ getContent<T extends IMovable.IContent = IMovable.IContent>(): T;
60
+ /**
61
+ * Deletes the content, which removes this movable. The same as `getContent().delete()`.
62
+ */
63
+ delete(): void;
57
64
  /**
58
65
  * Selects the current movable.
59
66
  *
@@ -90,30 +97,6 @@ export interface IMovable extends IAnchored, ITransaction.ITransactional, IHisto
90
97
  * Returns the absolute bounds of the movable object in pixels or `null` if not yet laid out.
91
98
  */
92
99
  getBounds(): Bounds | null;
93
- /**
94
- * Set the name for a movable object.
95
- *
96
- * @param name The name of the IMovable.
97
- */
98
- setName(name: string): IMovable;
99
- /**
100
- * @see
101
- * {@link setName}
102
- *
103
- * @returns The name or `null` if the movable has been deleted.
104
- */
105
- getName(): string | null;
106
- /**
107
- * This is the alternative text use for assistive technologies.
108
- */
109
- setDescription(description: string | null): IMovable;
110
- /**
111
- * @see
112
- * {@link setDescription}
113
- *
114
- * @returns The description or `null` if none has been set (or the movable has been deleted).
115
- */
116
- getDescription(): string | null;
117
100
  /**
118
101
  * If true then the movable object is hidden.
119
102
  */
@@ -194,6 +177,61 @@ export interface IMovable extends IAnchored, ITransaction.ITransactional, IHisto
194
177
  * {@link IMovable}
195
178
  */
196
179
  export declare namespace IMovable {
180
+ /**
181
+ * What a movable draws: a chart, a picture, a shape, a slicer, a control.
182
+ *
183
+ * @remarks
184
+ * Content owns what identifies it, and the movable owns where it is drawn. Content can exist
185
+ * with no movable: a picture used as a sheet background is not placed by one.
186
+ */
187
+ interface IContent {
188
+ /**
189
+ * Returns an immutable type string.
190
+ */
191
+ getType(): string;
192
+ /**
193
+ * Returns the id of the content.
194
+ */
195
+ getId(): string;
196
+ /**
197
+ * Returns the name, or `null` if the content has none.
198
+ *
199
+ * @remarks
200
+ * Not defined for content that is never named.
201
+ */
202
+ getName?(): string | null;
203
+ /**
204
+ * Set the name.
205
+ *
206
+ * @param name The name of the content.
207
+ */
208
+ setName?(name: string): this;
209
+ /**
210
+ * Returns the alternative text used by assistive technologies, or `null` if none has been set.
211
+ */
212
+ getDescription(): string | null;
213
+ /**
214
+ * Set the alternative text used by assistive technologies.
215
+ */
216
+ setDescription(description: string | null): this;
217
+ /**
218
+ * Returns a label for the kind of content, such as `Chart` or `Picture`.
219
+ */
220
+ getTypeDescription(): string;
221
+ /**
222
+ * Returns the movable that places the content on the sheet, or `null` if it is not placed by
223
+ * one.
224
+ */
225
+ getMovable(): IMovable | null;
226
+ /**
227
+ * Deletes the content, and with it the movable that places it.
228
+ */
229
+ delete(options?: ITransaction.OperationOptions): void;
230
+ /**
231
+ * Returns `true` if the content has been deleted.
232
+ */
233
+ isDeleted(): boolean;
234
+ }
197
235
  /**
198
236
  * Extends {@link ITypes.SelectOptions} to include options for `IMovable`.
199
237
  */
@@ -216,11 +254,7 @@ export declare namespace IMovable {
216
254
  */
217
255
  onSelectionChange?(source: IMovable): void;
218
256
  /**
219
- * Called when the name has changed.
220
- */
221
- onNameChange?(source: IMovable): void;
222
- /**
223
- * Called when selection changes.
257
+ * Called when the bounds have changed.
224
258
  */
225
259
  onBoundsChange?(source: IMovable): void;
226
260
  /**
@@ -296,6 +330,14 @@ export declare namespace IMovable {
296
330
  * This must align to a known movable object type. Defined in the IEmbeddedDrawing interface.
297
331
  */
298
332
  type: string;
333
+ /**
334
+ * The name of the content.
335
+ */
336
+ name?: string;
337
+ /**
338
+ * The alternative text used by assistive technologies.
339
+ */
340
+ description?: string;
299
341
  /**
300
342
  * Underlying json.
301
343
  */
@@ -314,16 +356,6 @@ export declare namespace IMovable {
314
356
  * The behavior of how the movable resizes as the anchor/cells change.
315
357
  */
316
358
  anchorType?: IAnchored.Type;
317
- /**
318
- * The name of the movable object.
319
- */
320
- name?: string;
321
- /**
322
- * This is the alternative text use for assistive technologies.
323
- *
324
- * @defaultValue null
325
- */
326
- description?: string;
327
359
  /**
328
360
  * If true then the movable object is hidden.
329
361
  *
@@ -99,6 +99,12 @@ export declare namespace IMovableCollection {
99
99
  * Initial json value.
100
100
  */
101
101
  json?: J;
102
+ /**
103
+ * The name of the content.
104
+ *
105
+ * @defaultValue A name made from the type, such as `Chart 3`.
106
+ */
107
+ name?: string;
102
108
  /**
103
109
  * If a referenceId is provided then the movable will be linked to the resource.
104
110
  * @param resourceId