@cratis/scene.model 4.22.1 → 4.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/descriptors/ComponentCategory.ts +40 -0
  2. package/descriptors/ComponentDescriptor.ts +22 -1
  3. package/descriptors/ComponentDesignModeDescriptor.ts +76 -0
  4. package/descriptors/PropertyDescriptor.ts +5 -1
  5. package/descriptors/PropertyEditorKind.ts +56 -1
  6. package/descriptors/PropertyEditorOptions.ts +51 -0
  7. package/descriptors/componentIcon.ts +16 -0
  8. package/descriptors/index.ts +4 -0
  9. package/dist/cjs/descriptors/ComponentCategory.js +25 -0
  10. package/dist/cjs/descriptors/ComponentCategory.js.map +1 -0
  11. package/dist/cjs/descriptors/ComponentDescriptor.js +5 -0
  12. package/dist/cjs/descriptors/ComponentDescriptor.js.map +1 -1
  13. package/dist/cjs/descriptors/ComponentDesignModeDescriptor.js +28 -0
  14. package/dist/cjs/descriptors/ComponentDesignModeDescriptor.js.map +1 -0
  15. package/dist/cjs/descriptors/PropertyDescriptor.js +1 -0
  16. package/dist/cjs/descriptors/PropertyDescriptor.js.map +1 -1
  17. package/dist/cjs/descriptors/PropertyEditorKind.js +23 -2
  18. package/dist/cjs/descriptors/PropertyEditorKind.js.map +1 -1
  19. package/dist/cjs/descriptors/PropertyEditorOptions.js +25 -0
  20. package/dist/cjs/descriptors/PropertyEditorOptions.js.map +1 -0
  21. package/dist/cjs/descriptors/componentIcon.js +19 -0
  22. package/dist/cjs/descriptors/componentIcon.js.map +1 -0
  23. package/dist/cjs/editing/DiagnosticCode.js +5 -0
  24. package/dist/cjs/editing/DiagnosticCode.js.map +1 -1
  25. package/dist/cjs/index.js +23 -0
  26. package/dist/cjs/index.js.map +1 -1
  27. package/dist/cjs/structure/ApplicationStructure.js +10 -0
  28. package/dist/cjs/structure/ApplicationStructure.js.map +1 -0
  29. package/dist/cjs/structure/FeatureNode.js +13 -0
  30. package/dist/cjs/structure/FeatureNode.js.map +1 -0
  31. package/dist/cjs/structure/ModuleNode.js +13 -0
  32. package/dist/cjs/structure/ModuleNode.js.map +1 -0
  33. package/dist/cjs/structure/SliceKind.js +15 -0
  34. package/dist/cjs/structure/SliceKind.js.map +1 -0
  35. package/dist/cjs/structure/SliceNode.js +12 -0
  36. package/dist/cjs/structure/SliceNode.js.map +1 -0
  37. package/dist/esm/descriptors/ComponentCategory.d.ts +13 -0
  38. package/dist/esm/descriptors/ComponentCategory.d.ts.map +1 -0
  39. package/dist/esm/descriptors/ComponentCategory.js +22 -0
  40. package/dist/esm/descriptors/ComponentCategory.js.map +1 -0
  41. package/dist/esm/descriptors/ComponentDescriptor.d.ts +7 -0
  42. package/dist/esm/descriptors/ComponentDescriptor.d.ts.map +1 -1
  43. package/dist/esm/descriptors/ComponentDescriptor.js +5 -0
  44. package/dist/esm/descriptors/ComponentDescriptor.js.map +1 -1
  45. package/dist/esm/descriptors/ComponentDesignModeDescriptor.d.ts +24 -0
  46. package/dist/esm/descriptors/ComponentDesignModeDescriptor.d.ts.map +1 -0
  47. package/dist/esm/descriptors/ComponentDesignModeDescriptor.js +24 -0
  48. package/dist/esm/descriptors/ComponentDesignModeDescriptor.js.map +1 -0
  49. package/dist/esm/descriptors/PropertyDescriptor.d.ts +2 -0
  50. package/dist/esm/descriptors/PropertyDescriptor.d.ts.map +1 -1
  51. package/dist/esm/descriptors/PropertyDescriptor.js +1 -0
  52. package/dist/esm/descriptors/PropertyDescriptor.js.map +1 -1
  53. package/dist/esm/descriptors/PropertyEditorKind.d.ts +17 -0
  54. package/dist/esm/descriptors/PropertyEditorKind.d.ts.map +1 -1
  55. package/dist/esm/descriptors/PropertyEditorKind.js +23 -2
  56. package/dist/esm/descriptors/PropertyEditorKind.js.map +1 -1
  57. package/dist/esm/descriptors/PropertyEditorOptions.d.ts +18 -0
  58. package/dist/esm/descriptors/PropertyEditorOptions.d.ts.map +1 -0
  59. package/dist/esm/descriptors/PropertyEditorOptions.js +22 -0
  60. package/dist/esm/descriptors/PropertyEditorOptions.js.map +1 -0
  61. package/dist/esm/descriptors/componentIcon.d.ts +4 -0
  62. package/dist/esm/descriptors/componentIcon.d.ts.map +1 -0
  63. package/dist/esm/descriptors/componentIcon.js +16 -0
  64. package/dist/esm/descriptors/componentIcon.js.map +1 -0
  65. package/dist/esm/descriptors/index.d.ts +4 -0
  66. package/dist/esm/descriptors/index.d.ts.map +1 -1
  67. package/dist/esm/descriptors/index.js +4 -0
  68. package/dist/esm/descriptors/index.js.map +1 -1
  69. package/dist/esm/editing/DiagnosticCode.d.ts +5 -1
  70. package/dist/esm/editing/DiagnosticCode.d.ts.map +1 -1
  71. package/dist/esm/editing/DiagnosticCode.js +5 -0
  72. package/dist/esm/editing/DiagnosticCode.js.map +1 -1
  73. package/dist/esm/index.d.ts +1 -0
  74. package/dist/esm/index.d.ts.map +1 -1
  75. package/dist/esm/index.js +9 -0
  76. package/dist/esm/index.js.map +1 -1
  77. package/dist/esm/structure/ApplicationStructure.d.ts +6 -0
  78. package/dist/esm/structure/ApplicationStructure.d.ts.map +1 -0
  79. package/dist/esm/structure/ApplicationStructure.js +8 -0
  80. package/dist/esm/structure/ApplicationStructure.js.map +1 -0
  81. package/dist/esm/structure/FeatureNode.d.ts +9 -0
  82. package/dist/esm/structure/FeatureNode.d.ts.map +1 -0
  83. package/dist/esm/structure/FeatureNode.js +11 -0
  84. package/dist/esm/structure/FeatureNode.js.map +1 -0
  85. package/dist/esm/structure/ModuleNode.d.ts +10 -0
  86. package/dist/esm/structure/ModuleNode.d.ts.map +1 -0
  87. package/dist/esm/structure/ModuleNode.js +11 -0
  88. package/dist/esm/structure/ModuleNode.js.map +1 -0
  89. package/dist/esm/structure/SliceKind.d.ts +6 -0
  90. package/dist/esm/structure/SliceKind.d.ts.map +1 -0
  91. package/dist/esm/structure/SliceKind.js +13 -0
  92. package/dist/esm/structure/SliceKind.js.map +1 -0
  93. package/dist/esm/structure/SliceNode.d.ts +8 -0
  94. package/dist/esm/structure/SliceNode.d.ts.map +1 -0
  95. package/dist/esm/structure/SliceNode.js +10 -0
  96. package/dist/esm/structure/SliceNode.js.map +1 -0
  97. package/dist/esm/structure/index.d.ts +6 -0
  98. package/dist/esm/structure/index.d.ts.map +1 -0
  99. package/dist/esm/structure/index.js +6 -0
  100. package/dist/esm/structure/index.js.map +1 -0
  101. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  102. package/editing/DiagnosticCode.ts +6 -0
  103. package/index.ts +1 -0
  104. package/package.json +1 -1
  105. package/structure/ApplicationStructure.ts +17 -0
  106. package/structure/FeatureNode.ts +23 -0
  107. package/structure/ModuleNode.ts +24 -0
  108. package/structure/SliceKind.ts +16 -0
  109. package/structure/SliceNode.ts +20 -0
  110. package/structure/index.ts +8 -0
@@ -0,0 +1,40 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * The categories a component picker groups components under. Every component declares exactly one (rule CMP1).
6
+ *
7
+ * The set is open: a package may declare a category of its own, which a validation reports as a warning
8
+ * ({@link DiagnosticCode.ComponentCategoryUnknown}) rather than refusing, so a picker shows it as a group of its own.
9
+ * Matching is by the exact words below.
10
+ */
11
+ export const ComponentCategory = {
12
+ /** Moves the user between places: topbar, sidebar, tabs, breadcrumbs, stepper. */
13
+ Navigation: 'Navigation',
14
+
15
+ /** Shows data: data table, list, card grid, board, timeline, stat card, chart. */
16
+ DataDisplay: 'Data display',
17
+
18
+ /** Takes a value from the user: text field, select, date picker, tag input, lookup. */
19
+ Input: 'Input',
20
+
21
+ /** Starts something: button, toolbar, menu, command bar. */
22
+ Actions: 'Actions',
23
+
24
+ /** Arranges other components: stack, grid, split pane, card, section. */
25
+ Layout: 'Layout',
26
+
27
+ /** Tells the user what happened or is happening: alert, toast, empty state, progress. */
28
+ Feedback: 'Feedback',
29
+
30
+ /** Appears over the page: dialog, side sheet, popover. */
31
+ Overlay: 'Overlay',
32
+
33
+ /** Collects a command's input: form, wizard, field group. */
34
+ Forms: 'Forms',
35
+ } as const;
36
+
37
+ export type ComponentCategory = (typeof ComponentCategory)[keyof typeof ComponentCategory];
38
+
39
+ /** Every category this model defines, in the order a picker lists them. */
40
+ export const componentCategories: readonly string[] = Object.values(ComponentCategory);
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Cratis. All rights reserved.
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
+ import { IconReference } from '../icons';
5
+ import { ComponentDesignModeDescriptor } from './ComponentDesignModeDescriptor';
4
6
  import { DesignTimeActionDescriptor } from './DesignTimeActionDescriptor';
5
7
  import { PropertyDescriptor } from './PropertyDescriptor';
6
8
 
@@ -23,6 +25,25 @@ export interface ComponentDescriptor {
23
25
 
24
26
  description?: string;
25
27
 
28
+ /**
29
+ * The group a component picker lists the component under (rule CMP1: every component declares one). One of
30
+ * {@link ComponentCategory}, or a category the package adds. Optional in the type so a descriptor can be built up in steps;
31
+ * `validateComponentDescriptors` reports a component that ends without one.
32
+ */
33
+ category?: string;
34
+
35
+ /** The icon a picker shows for the component. */
36
+ icon?: IconReference;
37
+
38
+ /** Two letters a picker shows when it has no icon to draw. Absent means derive them from `displayName` (`componentBadge`). */
39
+ badge?: string;
40
+
41
+ /** Words a picker's filter matches besides the name and the category - "grid" for a data table. */
42
+ keywords?: string[];
43
+
44
+ /** How the component is edited directly on the design surface, as data. */
45
+ designMode?: ComponentDesignModeDescriptor;
46
+
26
47
  /** Names a specialised editor for the component as a whole, when its properties are not edited one by one. */
27
48
  editorKind?: string;
28
49
 
@@ -39,5 +60,5 @@ export interface ComponentDescriptor {
39
60
  }
40
61
 
41
62
  export const ComponentDescriptorPropertyNames: (keyof ComponentDescriptor)[] = [
42
- 'component', 'displayName', 'description', 'editorKind', 'properties', 'actions', 'previewKind', 'propertyDisplayKind',
63
+ 'component', 'displayName', 'description', 'category', 'icon', 'badge', 'keywords', 'designMode', 'editorKind', 'properties', 'actions', 'previewKind', 'propertyDisplayKind',
43
64
  ];
@@ -0,0 +1,76 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { IconReference } from '../icons';
5
+
6
+ /**
7
+ * An affordance a designer shows on the design surface to add an item to a component (the "+ Add tab" button of a tab strip,
8
+ * the "Add item" of a toolbar).
9
+ */
10
+ export interface DesignModeAddAction {
11
+ /** Stable identity, unique within the component. */
12
+ id: string;
13
+
14
+ /** The label the designer shows. */
15
+ label: string;
16
+
17
+ /** The icon the designer shows next to it. */
18
+ icon?: IconReference;
19
+
20
+ /**
21
+ * The `Collection` property of the component the new item is added to - the add is the ordinary `AddCollectionItem` edit. Absent,
22
+ * the item is added to the component's own items, which the host resolves (the navigation region of a topbar, the children of a
23
+ * toolbar).
24
+ */
25
+ collectionPath?: string;
26
+ }
27
+
28
+ /**
29
+ * One button of the toolbar a designer shows over a selected item of a component.
30
+ *
31
+ * `availability` and `readOnlyReason` are rule *names*, interpreted by the package's design-time bundle exactly like
32
+ * {@link DesignTimeActionDescriptor.availability}. The model carries no functions.
33
+ */
34
+ export interface DesignModeItemAction {
35
+ /** Stable identity, unique within the component. */
36
+ id: string;
37
+
38
+ /** The icon of the button. */
39
+ icon: IconReference;
40
+
41
+ /** The tooltip and accessible name of the button. */
42
+ title: string;
43
+
44
+ /** The button is shown without its title, in a tight row. */
45
+ compact?: boolean;
46
+
47
+ /** Names the rule that decides whether the button is shown and enabled for an item. Absent means always. */
48
+ availability?: string;
49
+
50
+ /** Names the rule that says why a read-only (inherited) item hides or disables the button. */
51
+ readOnlyReason?: string;
52
+ }
53
+
54
+ /**
55
+ * How a component is edited directly on the design surface: where its items are and which affordances the designer offers for
56
+ * them. Plain data - a Visual Studio-style designer reads it without loading the component. Every edit it causes is a normal model edit
57
+ * (`AddCollectionItem`, `RemoveCollectionItem`, `ReorderCollectionItems`, `EditCollectionItem`), so undo, redo and the dirty state
58
+ * need nothing of their own.
59
+ */
60
+ export interface ComponentDesignModeDescriptor {
61
+ /**
62
+ * The `Collection` property whose rows are the component's items. Absent when the items are not a property of the
63
+ * component but something the host resolves - the navigation items of a topbar, the children of a toolbar.
64
+ */
65
+ itemsPath?: string;
66
+
67
+ /** The "add" affordances. */
68
+ addActions: DesignModeAddAction[];
69
+
70
+ /** The buttons over a selected item. */
71
+ itemToolbar: DesignModeItemAction[];
72
+ }
73
+
74
+ export const DesignModeAddActionPropertyNames: (keyof DesignModeAddAction)[] = ['id', 'label', 'icon', 'collectionPath'];
75
+ export const DesignModeItemActionPropertyNames: (keyof DesignModeItemAction)[] = ['id', 'icon', 'title', 'compact', 'availability', 'readOnlyReason'];
76
+ export const ComponentDesignModeDescriptorPropertyNames: (keyof ComponentDesignModeDescriptor)[] = ['itemsPath', 'addActions', 'itemToolbar'];
@@ -5,6 +5,7 @@ import { BindingMode, BindingSourceKind } from '../common';
5
5
  import { CollectionItemDescriptor } from './CollectionItemDescriptor';
6
6
  import { PropertyChoice } from './PropertyChoice';
7
7
  import { PropertyConstraints } from './PropertyConstraints';
8
+ import { PropertyEditorOptions } from './PropertyEditorOptions';
8
9
  import { PropertyValueType } from './PropertyValueType';
9
10
 
10
11
  /**
@@ -41,6 +42,9 @@ export interface PropertyDescriptor {
41
42
  */
42
43
  editorKind?: string;
43
44
 
45
+ /** The parameters of the named editor - multi-line, placeholder, unit, step, slice kinds, the reference filter. */
46
+ editorOptions?: PropertyEditorOptions;
47
+
44
48
  /** A sentence of help for the editor. */
45
49
  description?: string;
46
50
 
@@ -75,6 +79,6 @@ export interface PropertyDescriptor {
75
79
  }
76
80
 
77
81
  export const PropertyDescriptorPropertyNames: (keyof PropertyDescriptor)[] = [
78
- 'path', 'label', 'group', 'valueType', 'choices', 'default', 'constraints', 'editorKind', 'description', 'item', 'properties', 'open', 'readOnly',
82
+ 'path', 'label', 'group', 'valueType', 'choices', 'default', 'constraints', 'editorKind', 'editorOptions', 'description', 'item', 'properties', 'open', 'readOnly',
79
83
  'output', 'acceptedBindingKinds', 'bindingMode',
80
84
  ];
@@ -2,7 +2,11 @@
2
2
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
 
4
4
  /**
5
- * The editor kinds for values that have no fields to describe, so a host can edit them without asking for JSON text.
5
+ * The editor ids Studio's property-editor registry resolves (spec section 8). A property names one in `editorKind`; a host that
6
+ * does not know the id falls back to the default editor for `valueType`, and a package may name ids of its own (they are strings).
7
+ * This vocabulary defines only the ids and, in {@link PropertyEditorOptions}, their parameters - the editors themselves belong to the host.
8
+ *
9
+ * It starts with the editors for values that have no fields to describe, so a host can edit them without asking for JSON text.
6
10
  *
7
11
  * A list of plain values is a `json` property - Scene keeps the array exactly as authored - whose `editorKind` says what
8
12
  * its entries are. A record whose keys are the author's own (a row of data, keyed by column) is an `object` property
@@ -23,6 +27,57 @@ export const PropertyEditorKind = {
23
27
 
24
28
  /** A record of words, numbers and flags under names the author chooses. */
25
29
  StringMap: 'stringMap',
30
+
31
+ /** A single line of text; `editorOptions.multiline` makes it a box, `editorOptions.placeholder` hints it. */
32
+ Text: 'text',
33
+
34
+ /** A number; `constraints.minimum`/`maximum` and `editorOptions.step`/`unit` shape it. */
35
+ Number: 'number',
36
+
37
+ /** A switch with a label. */
38
+ Boolean: 'boolean',
39
+
40
+ /** Up to four choices as segmented chips. */
41
+ Enum: 'enum',
42
+
43
+ /** Any number of choices as a dropdown with a filter. */
44
+ Select: 'select',
45
+
46
+ /** A theme token first, a custom colour second. */
47
+ Color: 'color',
48
+
49
+ /** An icon from a searchable grid. */
50
+ Icon: 'icon',
51
+
52
+ /** A list of simple items: add, remove, reorder rows. */
53
+ List: 'list',
54
+
55
+ /** The id of another model element, from a searchable dropdown restricted by `editorOptions.reference`. */
56
+ Reference: 'reference',
57
+
58
+ /** The target of a navigation item: a Module > Feature tree, shown as a breadcrumb when closed. */
59
+ NavigationTarget: 'navigationTarget',
60
+
61
+ /** One of the slots of the effective template, with a mini diagram of its position. */
62
+ RenderingSlot: 'renderingSlot',
63
+
64
+ /** A slice from the slice tree; `editorOptions.kinds` (for example `['StateChange']`) filters, the rest are listed disabled with a reason. */
65
+ Slice: 'slice',
66
+
67
+ /** How a region relates to what it inherits: `inherit`, `extend` or `override`, as a three-way control. */
68
+ InheritanceMode: 'inheritanceMode',
69
+
70
+ /** A reference to a template, chosen through the template picker. */
71
+ Template: 'template',
72
+
73
+ /** A reference to a sample data pack. */
74
+ SampleData: 'sampleData',
75
+
76
+ /** A field of the shape a component is bound to, typed by `editorOptions.fieldKinds`. */
77
+ Field: 'field',
78
+
79
+ /** The columns of a table: rows of `{ field, header, width, align, format }`. */
80
+ ColumnList: 'columnList',
26
81
  } as const;
27
82
 
28
83
  export type PropertyEditorKind = (typeof PropertyEditorKind)[keyof typeof PropertyEditorKind];
@@ -0,0 +1,51 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * What a `reference` editor offers: the model elements of one kind, narrowed by a named rule.
6
+ */
7
+ export interface ReferenceFilterDescriptor {
8
+ /** The kind of model element referenced: `screen`, `slice`, `template`, `shape`, `field` ... A host maps it to what it can list. */
9
+ target: string;
10
+
11
+ /** Narrows the target to these kinds (a slice is a `StateChange`, a `ReadModel` ...). Absent means every kind. */
12
+ kinds?: string[];
13
+
14
+ /** Names the rule that decides which candidates are offered, interpreted by the host - like `availability` of a design-time action. */
15
+ predicate?: string;
16
+ }
17
+
18
+ /**
19
+ * The parameters of a named editor, alongside `PropertyDescriptor.editorKind`: the bits a generic editor needs that are not a value
20
+ * constraint. Every field is optional and only the ones an editor documents are read.
21
+ */
22
+ export interface PropertyEditorOptions {
23
+ /** `text`: a multi-line box instead of a single line. */
24
+ multiline?: boolean;
25
+
26
+ /** `text`: the hint shown while empty. */
27
+ placeholder?: string;
28
+
29
+ /** `number`: the unit shown after the value (`px`, `%`, `ms`). */
30
+ unit?: string;
31
+
32
+ /** `number`: the increment of a stepper. The range is `constraints.minimum` and `constraints.maximum`. */
33
+ step?: number;
34
+
35
+ /** `slice`: the slice kinds that can be chosen (`['StateChange']`); others are listed disabled with a reason. */
36
+ kinds?: string[];
37
+
38
+ /** `reference`: what can be referenced. Required by the `reference` editor. */
39
+ reference?: ReferenceFilterDescriptor;
40
+
41
+ /** `field`: the kinds of field offered (`string`, `number`, `boolean` ...). Absent means any. */
42
+ fieldKinds?: string[];
43
+
44
+ /** `color`: only theme tokens, no custom colour. */
45
+ tokensOnly?: boolean;
46
+ }
47
+
48
+ export const ReferenceFilterDescriptorPropertyNames: (keyof ReferenceFilterDescriptor)[] = ['target', 'kinds', 'predicate'];
49
+ export const PropertyEditorOptionsPropertyNames: (keyof PropertyEditorOptions)[] = [
50
+ 'multiline', 'placeholder', 'unit', 'step', 'kinds', 'reference', 'fieldKinds', 'tokensOnly',
51
+ ];
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { IconReference } from '../icons';
5
+
6
+ /**
7
+ * The icon library the built-in components' icons come from: the Lucide library package a Cratis host ships. A component's icon is an
8
+ * ordinary {@link IconReference}, so a host without that library shows the component's badge instead (see the component picker) and
9
+ * the icon diagnostics report it like any other icon.
10
+ */
11
+ export const componentIconLibrary = 'Cratis.Icons.Lucide';
12
+
13
+ /** The icon with this key in {@link componentIconLibrary}. */
14
+ export function componentIcon(key: string): IconReference {
15
+ return { library: componentIconLibrary, key };
16
+ }
@@ -3,6 +3,7 @@
3
3
 
4
4
  export * from './PropertyValueType';
5
5
  export * from './PropertyEditorKind';
6
+ export * from './PropertyEditorOptions';
6
7
  export * from './PropertyChoice';
7
8
  export * from './PropertyConstraints';
8
9
  export * from './CollectionItemDescriptor';
@@ -10,6 +11,9 @@ export * from './DesignTimeActionDescriptor';
10
11
  export * from './DesignTimeActionPlacement';
11
12
  export * from './PackageDesignTimeMetadata';
12
13
  export * from './PropertyDescriptor';
14
+ export * from './ComponentCategory';
15
+ export * from './ComponentDesignModeDescriptor';
16
+ export * from './componentIcon';
13
17
  export * from './ComponentDescriptor';
14
18
  export * from './CollectionOperation';
15
19
  export * from './LayoutType';
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The categories a component picker groups components under. Every component declares exactly one (rule CMP1).
7
+ *
8
+ * The set is open: a package may declare a category of its own, which a validation reports as a warning
9
+ * ({@link DiagnosticCode.ComponentCategoryUnknown}) rather than refusing, so a picker shows it as a group of its own.
10
+ * Matching is by the exact words below.
11
+ */ const ComponentCategory = {
12
+ /** Moves the user between places: topbar, sidebar, tabs, breadcrumbs, stepper. */ Navigation: 'Navigation',
13
+ /** Shows data: data table, list, card grid, board, timeline, stat card, chart. */ DataDisplay: 'Data display',
14
+ /** Takes a value from the user: text field, select, date picker, tag input, lookup. */ Input: 'Input',
15
+ /** Starts something: button, toolbar, menu, command bar. */ Actions: 'Actions',
16
+ /** Arranges other components: stack, grid, split pane, card, section. */ Layout: 'Layout',
17
+ /** Tells the user what happened or is happening: alert, toast, empty state, progress. */ Feedback: 'Feedback',
18
+ /** Appears over the page: dialog, side sheet, popover. */ Overlay: 'Overlay',
19
+ /** Collects a command's input: form, wizard, field group. */ Forms: 'Forms'
20
+ };
21
+ /** Every category this model defines, in the order a picker lists them. */ const componentCategories = Object.values(ComponentCategory);
22
+
23
+ exports.ComponentCategory = ComponentCategory;
24
+ exports.componentCategories = componentCategories;
25
+ //# sourceMappingURL=ComponentCategory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentCategory.js","sources":["../../../descriptors/ComponentCategory.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The categories a component picker groups components under. Every component declares exactly one (rule CMP1).\n *\n * The set is open: a package may declare a category of its own, which a validation reports as a warning\n * ({@link DiagnosticCode.ComponentCategoryUnknown}) rather than refusing, so a picker shows it as a group of its own.\n * Matching is by the exact words below.\n */\nexport const ComponentCategory = {\n /** Moves the user between places: topbar, sidebar, tabs, breadcrumbs, stepper. */\n Navigation: 'Navigation',\n\n /** Shows data: data table, list, card grid, board, timeline, stat card, chart. */\n DataDisplay: 'Data display',\n\n /** Takes a value from the user: text field, select, date picker, tag input, lookup. */\n Input: 'Input',\n\n /** Starts something: button, toolbar, menu, command bar. */\n Actions: 'Actions',\n\n /** Arranges other components: stack, grid, split pane, card, section. */\n Layout: 'Layout',\n\n /** Tells the user what happened or is happening: alert, toast, empty state, progress. */\n Feedback: 'Feedback',\n\n /** Appears over the page: dialog, side sheet, popover. */\n Overlay: 'Overlay',\n\n /** Collects a command's input: form, wizard, field group. */\n Forms: 'Forms',\n} as const;\n\nexport type ComponentCategory = (typeof ComponentCategory)[keyof typeof ComponentCategory];\n\n/** Every category this model defines, in the order a picker lists them. */\nexport const componentCategories: readonly string[] = Object.values(ComponentCategory);\n"],"names":["ComponentCategory","Navigation","DataDisplay","Input","Actions","Layout","Feedback","Overlay","Forms","componentCategories","Object","values"],"mappings":";;AAAA;AACA;AAEA;;;;;;UAOaA,iBAAAA,GAAoB;AAC7B,uFACAC,UAAAA,EAAY,YAAA;AAEZ,uFACAC,WAAAA,EAAa,cAAA;AAEb,4FACAC,KAAAA,EAAO,OAAA;AAEP,iEACAC,OAAAA,EAAS,SAAA;AAET,8EACAC,MAAAA,EAAQ,QAAA;AAER,8FACAC,QAAAA,EAAU,UAAA;AAEV,+DACAC,OAAAA,EAAS,SAAA;AAET,kEACAC,KAAAA,EAAO;AACX;AAIA,4EACO,MAAMC,sBAAyCC,MAAAA,CAAOC,MAAM,CAACX,iBAAAA;;;"}
@@ -6,6 +6,11 @@ const ComponentDescriptorPropertyNames = [
6
6
  'component',
7
7
  'displayName',
8
8
  'description',
9
+ 'category',
10
+ 'icon',
11
+ 'badge',
12
+ 'keywords',
13
+ 'designMode',
9
14
  'editorKind',
10
15
  'properties',
11
16
  'actions',
@@ -1 +1 @@
1
- {"version":3,"file":"ComponentDescriptor.js","sources":["../../../descriptors/ComponentDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DesignTimeActionDescriptor } from './DesignTimeActionDescriptor';\nimport { PropertyDescriptor } from './PropertyDescriptor';\n\n/**\n * What can be edited on one component a package provides.\n *\n * Packages contribute these alongside the components themselves (a bundle's `descriptors`), through the same\n * package mechanism that already carries components, layouts and themes - there is no second registry to keep in\n * step.\n */\nexport interface ComponentDescriptor {\n /**\n * The component this describes, as the package names it: `<package>:<bare name>`, the same key a bundle\n * registers the component under (for example `Cratis.Components:dataTable`).\n */\n component: string;\n\n /** A human-readable name for a palette or an inspector title. */\n displayName?: string;\n\n description?: string;\n\n /** Names a specialised editor for the component as a whole, when its properties are not edited one by one. */\n editorKind?: string;\n\n properties: PropertyDescriptor[];\n\n /** Package-provided design-time actions for this component. */\n actions?: DesignTimeActionDescriptor[];\n\n /** Names an optional package-provided preview renderer. */\n previewKind?: string;\n\n /** Names an optional package-provided property display renderer set. */\n propertyDisplayKind?: string;\n}\n\nexport const ComponentDescriptorPropertyNames: (keyof ComponentDescriptor)[] = [\n 'component', 'displayName', 'description', 'editorKind', 'properties', 'actions', 'previewKind', 'propertyDisplayKind',\n];\n"],"names":["ComponentDescriptorPropertyNames"],"mappings":";;AAAA;AACA;MAuCaA,gCAAAA,GAAkE;AAC3E,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA,aAAA;AAAe,IAAA,YAAA;AAAc,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,aAAA;AAAe,IAAA;;;"}
1
+ {"version":3,"file":"ComponentDescriptor.js","sources":["../../../descriptors/ComponentDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IconReference } from '../icons';\nimport { ComponentDesignModeDescriptor } from './ComponentDesignModeDescriptor';\nimport { DesignTimeActionDescriptor } from './DesignTimeActionDescriptor';\nimport { PropertyDescriptor } from './PropertyDescriptor';\n\n/**\n * What can be edited on one component a package provides.\n *\n * Packages contribute these alongside the components themselves (a bundle's `descriptors`), through the same\n * package mechanism that already carries components, layouts and themes - there is no second registry to keep in\n * step.\n */\nexport interface ComponentDescriptor {\n /**\n * The component this describes, as the package names it: `<package>:<bare name>`, the same key a bundle\n * registers the component under (for example `Cratis.Components:dataTable`).\n */\n component: string;\n\n /** A human-readable name for a palette or an inspector title. */\n displayName?: string;\n\n description?: string;\n\n /**\n * The group a component picker lists the component under (rule CMP1: every component declares one). One of\n * {@link ComponentCategory}, or a category the package adds. Optional in the type so a descriptor can be built up in steps;\n * `validateComponentDescriptors` reports a component that ends without one.\n */\n category?: string;\n\n /** The icon a picker shows for the component. */\n icon?: IconReference;\n\n /** Two letters a picker shows when it has no icon to draw. Absent means derive them from `displayName` (`componentBadge`). */\n badge?: string;\n\n /** Words a picker's filter matches besides the name and the category - \"grid\" for a data table. */\n keywords?: string[];\n\n /** How the component is edited directly on the design surface, as data. */\n designMode?: ComponentDesignModeDescriptor;\n\n /** Names a specialised editor for the component as a whole, when its properties are not edited one by one. */\n editorKind?: string;\n\n properties: PropertyDescriptor[];\n\n /** Package-provided design-time actions for this component. */\n actions?: DesignTimeActionDescriptor[];\n\n /** Names an optional package-provided preview renderer. */\n previewKind?: string;\n\n /** Names an optional package-provided property display renderer set. */\n propertyDisplayKind?: string;\n}\n\nexport const ComponentDescriptorPropertyNames: (keyof ComponentDescriptor)[] = [\n 'component', 'displayName', 'description', 'category', 'icon', 'badge', 'keywords', 'designMode', 'editorKind', 'properties', 'actions', 'previewKind', 'propertyDisplayKind',\n];\n"],"names":["ComponentDescriptorPropertyNames"],"mappings":";;AAAA;AACA;MA4DaA,gCAAAA,GAAkE;AAC3E,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA,aAAA;AAAe,IAAA,UAAA;AAAY,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,UAAA;AAAY,IAAA,YAAA;AAAc,IAAA,YAAA;AAAc,IAAA,YAAA;AAAc,IAAA,SAAA;AAAW,IAAA,aAAA;AAAe,IAAA;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ const DesignModeAddActionPropertyNames = [
6
+ 'id',
7
+ 'label',
8
+ 'icon',
9
+ 'collectionPath'
10
+ ];
11
+ const DesignModeItemActionPropertyNames = [
12
+ 'id',
13
+ 'icon',
14
+ 'title',
15
+ 'compact',
16
+ 'availability',
17
+ 'readOnlyReason'
18
+ ];
19
+ const ComponentDesignModeDescriptorPropertyNames = [
20
+ 'itemsPath',
21
+ 'addActions',
22
+ 'itemToolbar'
23
+ ];
24
+
25
+ exports.ComponentDesignModeDescriptorPropertyNames = ComponentDesignModeDescriptorPropertyNames;
26
+ exports.DesignModeAddActionPropertyNames = DesignModeAddActionPropertyNames;
27
+ exports.DesignModeItemActionPropertyNames = DesignModeItemActionPropertyNames;
28
+ //# sourceMappingURL=ComponentDesignModeDescriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentDesignModeDescriptor.js","sources":["../../../descriptors/ComponentDesignModeDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IconReference } from '../icons';\n\n/**\n * An affordance a designer shows on the design surface to add an item to a component (the \"+ Add tab\" button of a tab strip,\n * the \"Add item\" of a toolbar).\n */\nexport interface DesignModeAddAction {\n /** Stable identity, unique within the component. */\n id: string;\n\n /** The label the designer shows. */\n label: string;\n\n /** The icon the designer shows next to it. */\n icon?: IconReference;\n\n /**\n * The `Collection` property of the component the new item is added to - the add is the ordinary `AddCollectionItem` edit. Absent,\n * the item is added to the component's own items, which the host resolves (the navigation region of a topbar, the children of a\n * toolbar).\n */\n collectionPath?: string;\n}\n\n/**\n * One button of the toolbar a designer shows over a selected item of a component.\n *\n * `availability` and `readOnlyReason` are rule *names*, interpreted by the package's design-time bundle exactly like\n * {@link DesignTimeActionDescriptor.availability}. The model carries no functions.\n */\nexport interface DesignModeItemAction {\n /** Stable identity, unique within the component. */\n id: string;\n\n /** The icon of the button. */\n icon: IconReference;\n\n /** The tooltip and accessible name of the button. */\n title: string;\n\n /** The button is shown without its title, in a tight row. */\n compact?: boolean;\n\n /** Names the rule that decides whether the button is shown and enabled for an item. Absent means always. */\n availability?: string;\n\n /** Names the rule that says why a read-only (inherited) item hides or disables the button. */\n readOnlyReason?: string;\n}\n\n/**\n * How a component is edited directly on the design surface: where its items are and which affordances the designer offers for\n * them. Plain data - a Visual Studio-style designer reads it without loading the component. Every edit it causes is a normal model edit\n * (`AddCollectionItem`, `RemoveCollectionItem`, `ReorderCollectionItems`, `EditCollectionItem`), so undo, redo and the dirty state\n * need nothing of their own.\n */\nexport interface ComponentDesignModeDescriptor {\n /**\n * The `Collection` property whose rows are the component's items. Absent when the items are not a property of the\n * component but something the host resolves - the navigation items of a topbar, the children of a toolbar.\n */\n itemsPath?: string;\n\n /** The \"add\" affordances. */\n addActions: DesignModeAddAction[];\n\n /** The buttons over a selected item. */\n itemToolbar: DesignModeItemAction[];\n}\n\nexport const DesignModeAddActionPropertyNames: (keyof DesignModeAddAction)[] = ['id', 'label', 'icon', 'collectionPath'];\nexport const DesignModeItemActionPropertyNames: (keyof DesignModeItemAction)[] = ['id', 'icon', 'title', 'compact', 'availability', 'readOnlyReason'];\nexport const ComponentDesignModeDescriptorPropertyNames: (keyof ComponentDesignModeDescriptor)[] = ['itemsPath', 'addActions', 'itemToolbar'];\n"],"names":["DesignModeAddActionPropertyNames","DesignModeItemActionPropertyNames","ComponentDesignModeDescriptorPropertyNames"],"mappings":";;AAAA;AACA;MAwEaA,gCAAAA,GAAkE;AAAC,IAAA,IAAA;AAAM,IAAA,OAAA;AAAS,IAAA,MAAA;AAAQ,IAAA;;MAC1FC,iCAAAA,GAAoE;AAAC,IAAA,IAAA;AAAM,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,SAAA;AAAW,IAAA,cAAA;AAAgB,IAAA;;MACvHC,0CAAAA,GAAsF;AAAC,IAAA,WAAA;AAAa,IAAA,YAAA;AAAc,IAAA;;;;;"}
@@ -11,6 +11,7 @@ const PropertyDescriptorPropertyNames = [
11
11
  'default',
12
12
  'constraints',
13
13
  'editorKind',
14
+ 'editorOptions',
14
15
  'description',
15
16
  'item',
16
17
  'properties',
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyDescriptor.js","sources":["../../../descriptors/PropertyDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { BindingMode, BindingSourceKind } from '../common';\nimport { CollectionItemDescriptor } from './CollectionItemDescriptor';\nimport { PropertyChoice } from './PropertyChoice';\nimport { PropertyConstraints } from './PropertyConstraints';\nimport { PropertyValueType } from './PropertyValueType';\n\n/**\n * Describes one editable property of a node: where it lives, what it is called, what it may hold and how a host\n * should edit it. A descriptor is plain data, so packages ship them and Studio reads them without loading a\n * component.\n */\nexport interface PropertyDescriptor {\n /**\n * Where the value lives. For an `ExternalComponent` it is a key (or dotted key path) in the element's\n * `properties` bag; for a model-native node such as a flow container it is the node's own property name.\n */\n path: string;\n\n /** The label an editor shows. */\n label: string;\n\n /** The editor section the property belongs to. */\n group: string;\n\n valueType: PropertyValueType;\n\n /** The allowed values of an `Enum` property. */\n choices?: PropertyChoice[];\n\n /** The value in effect when none is set. */\n default?: unknown;\n\n constraints?: PropertyConstraints;\n\n /**\n * Names a specialised editor. A host maps the name to its own editor - an icon picker, a query binder - and\n * falls back to the default editor for `valueType` when it does not know the name.\n */\n editorKind?: string;\n\n /** A sentence of help for the editor. */\n description?: string;\n\n /** Describes the items of a `Collection` property. Required when `valueType` is `Collection`. */\n item?: CollectionItemDescriptor;\n\n /**\n * Describes the fields of an `Object` property. A field's `path` is a single name relative to the object, and\n * a field may itself be an `Object` or a `Collection`, so a structured value of any depth can be described.\n * Without it an `Object` value is only editable through a specialised `editorKind`.\n */\n properties?: PropertyDescriptor[];\n\n /**\n * An `Object` property's value may carry fields `properties` does not describe. They are kept as they are and never\n * edited. Without it a field the descriptor does not describe is refused. Use it when `properties` lists the fields an\n * editor offers but the stored value may legitimately have more - a chart dataset, a record read from a sample.\n */\n open?: boolean;\n\n /** The value is shown but never edited. */\n readOnly?: boolean;\n\n /** This property is emitted by the component and may be bound by other elements. */\n output?: boolean;\n\n /** Which binding source kinds may be assigned to this property. */\n acceptedBindingKinds?: BindingSourceKind[];\n\n /** The strongest binding mode the property supports. */\n bindingMode?: BindingMode;\n}\n\nexport const PropertyDescriptorPropertyNames: (keyof PropertyDescriptor)[] = [\n 'path', 'label', 'group', 'valueType', 'choices', 'default', 'constraints', 'editorKind', 'description', 'item', 'properties', 'open', 'readOnly',\n 'output', 'acceptedBindingKinds', 'bindingMode',\n];\n"],"names":["PropertyDescriptorPropertyNames"],"mappings":";;AAAA;AACA;MA2EaA,+BAAAA,GAAgE;AACzE,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,OAAA;AAAS,IAAA,WAAA;AAAa,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA,aAAA;AAAe,IAAA,YAAA;AAAc,IAAA,aAAA;AAAe,IAAA,MAAA;AAAQ,IAAA,YAAA;AAAc,IAAA,MAAA;AAAQ,IAAA,UAAA;AACvI,IAAA,QAAA;AAAU,IAAA,sBAAA;AAAwB,IAAA;;;"}
1
+ {"version":3,"file":"PropertyDescriptor.js","sources":["../../../descriptors/PropertyDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { BindingMode, BindingSourceKind } from '../common';\nimport { CollectionItemDescriptor } from './CollectionItemDescriptor';\nimport { PropertyChoice } from './PropertyChoice';\nimport { PropertyConstraints } from './PropertyConstraints';\nimport { PropertyEditorOptions } from './PropertyEditorOptions';\nimport { PropertyValueType } from './PropertyValueType';\n\n/**\n * Describes one editable property of a node: where it lives, what it is called, what it may hold and how a host\n * should edit it. A descriptor is plain data, so packages ship them and Studio reads them without loading a\n * component.\n */\nexport interface PropertyDescriptor {\n /**\n * Where the value lives. For an `ExternalComponent` it is a key (or dotted key path) in the element's\n * `properties` bag; for a model-native node such as a flow container it is the node's own property name.\n */\n path: string;\n\n /** The label an editor shows. */\n label: string;\n\n /** The editor section the property belongs to. */\n group: string;\n\n valueType: PropertyValueType;\n\n /** The allowed values of an `Enum` property. */\n choices?: PropertyChoice[];\n\n /** The value in effect when none is set. */\n default?: unknown;\n\n constraints?: PropertyConstraints;\n\n /**\n * Names a specialised editor. A host maps the name to its own editor - an icon picker, a query binder - and\n * falls back to the default editor for `valueType` when it does not know the name.\n */\n editorKind?: string;\n\n /** The parameters of the named editor - multi-line, placeholder, unit, step, slice kinds, the reference filter. */\n editorOptions?: PropertyEditorOptions;\n\n /** A sentence of help for the editor. */\n description?: string;\n\n /** Describes the items of a `Collection` property. Required when `valueType` is `Collection`. */\n item?: CollectionItemDescriptor;\n\n /**\n * Describes the fields of an `Object` property. A field's `path` is a single name relative to the object, and\n * a field may itself be an `Object` or a `Collection`, so a structured value of any depth can be described.\n * Without it an `Object` value is only editable through a specialised `editorKind`.\n */\n properties?: PropertyDescriptor[];\n\n /**\n * An `Object` property's value may carry fields `properties` does not describe. They are kept as they are and never\n * edited. Without it a field the descriptor does not describe is refused. Use it when `properties` lists the fields an\n * editor offers but the stored value may legitimately have more - a chart dataset, a record read from a sample.\n */\n open?: boolean;\n\n /** The value is shown but never edited. */\n readOnly?: boolean;\n\n /** This property is emitted by the component and may be bound by other elements. */\n output?: boolean;\n\n /** Which binding source kinds may be assigned to this property. */\n acceptedBindingKinds?: BindingSourceKind[];\n\n /** The strongest binding mode the property supports. */\n bindingMode?: BindingMode;\n}\n\nexport const PropertyDescriptorPropertyNames: (keyof PropertyDescriptor)[] = [\n 'path', 'label', 'group', 'valueType', 'choices', 'default', 'constraints', 'editorKind', 'editorOptions', 'description', 'item', 'properties', 'open', 'readOnly',\n 'output', 'acceptedBindingKinds', 'bindingMode',\n];\n"],"names":["PropertyDescriptorPropertyNames"],"mappings":";;AAAA;AACA;MA+EaA,+BAAAA,GAAgE;AACzE,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,OAAA;AAAS,IAAA,WAAA;AAAa,IAAA,SAAA;AAAW,IAAA,SAAA;AAAW,IAAA,aAAA;AAAe,IAAA,YAAA;AAAc,IAAA,eAAA;AAAiB,IAAA,aAAA;AAAe,IAAA,MAAA;AAAQ,IAAA,YAAA;AAAc,IAAA,MAAA;AAAQ,IAAA,UAAA;AACxJ,IAAA,QAAA;AAAU,IAAA,sBAAA;AAAwB,IAAA;;;"}
@@ -3,7 +3,11 @@
3
3
  // Copyright (c) Cratis. All rights reserved.
4
4
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
5
  /**
6
- * The editor kinds for values that have no fields to describe, so a host can edit them without asking for JSON text.
6
+ * The editor ids Studio's property-editor registry resolves (spec section 8). A property names one in `editorKind`; a host that
7
+ * does not know the id falls back to the default editor for `valueType`, and a package may name ids of its own (they are strings).
8
+ * This vocabulary defines only the ids and, in {@link PropertyEditorOptions}, their parameters - the editors themselves belong to the host.
9
+ *
10
+ * It starts with the editors for values that have no fields to describe, so a host can edit them without asking for JSON text.
7
11
  *
8
12
  * A list of plain values is a `json` property - Scene keeps the array exactly as authored - whose `editorKind` says what
9
13
  * its entries are. A record whose keys are the author's own (a row of data, keyed by column) is an `object` property
@@ -13,7 +17,24 @@
13
17
  /** An ordered list of numbers. */ NumberList: 'numberList',
14
18
  /** One word, or an ordered list of words: a chart colour is one colour for the series or one for each point. */ StringOrList: 'stringOrList',
15
19
  /** One word, number or flag - a value whose type the author chooses, such as the selected value of a control whose options carry any of them. */ Scalar: 'scalar',
16
- /** A record of words, numbers and flags under names the author chooses. */ StringMap: 'stringMap'
20
+ /** A record of words, numbers and flags under names the author chooses. */ StringMap: 'stringMap',
21
+ /** A single line of text; `editorOptions.multiline` makes it a box, `editorOptions.placeholder` hints it. */ Text: 'text',
22
+ /** A number; `constraints.minimum`/`maximum` and `editorOptions.step`/`unit` shape it. */ Number: 'number',
23
+ /** A switch with a label. */ Boolean: 'boolean',
24
+ /** Up to four choices as segmented chips. */ Enum: 'enum',
25
+ /** Any number of choices as a dropdown with a filter. */ Select: 'select',
26
+ /** A theme token first, a custom colour second. */ Color: 'color',
27
+ /** An icon from a searchable grid. */ Icon: 'icon',
28
+ /** A list of simple items: add, remove, reorder rows. */ List: 'list',
29
+ /** The id of another model element, from a searchable dropdown restricted by `editorOptions.reference`. */ Reference: 'reference',
30
+ /** The target of a navigation item: a Module > Feature tree, shown as a breadcrumb when closed. */ NavigationTarget: 'navigationTarget',
31
+ /** One of the slots of the effective template, with a mini diagram of its position. */ RenderingSlot: 'renderingSlot',
32
+ /** A slice from the slice tree; `editorOptions.kinds` (for example `['StateChange']`) filters, the rest are listed disabled with a reason. */ Slice: 'slice',
33
+ /** How a region relates to what it inherits: `inherit`, `extend` or `override`, as a three-way control. */ InheritanceMode: 'inheritanceMode',
34
+ /** A reference to a template, chosen through the template picker. */ Template: 'template',
35
+ /** A reference to a sample data pack. */ SampleData: 'sampleData',
36
+ /** A field of the shape a component is bound to, typed by `editorOptions.fieldKinds`. */ Field: 'field',
37
+ /** The columns of a table: rows of `{ field, header, width, align, format }`. */ ColumnList: 'columnList'
17
38
  };
18
39
 
19
40
  exports.PropertyEditorKind = PropertyEditorKind;
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyEditorKind.js","sources":["../../../descriptors/PropertyEditorKind.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The editor kinds for values that have no fields to describe, so a host can edit them without asking for JSON text.\n *\n * A list of plain values is a `json` property - Scene keeps the array exactly as authored - whose `editorKind` says what\n * its entries are. A record whose keys are the author's own (a row of data, keyed by column) is an `object` property\n * with no `properties` and the `stringMap` kind. A host that does not know a kind falls back to its default editor.\n */\nexport const PropertyEditorKind = {\n /** An ordered list of words. */\n StringList: 'stringList',\n\n /** An ordered list of numbers. */\n NumberList: 'numberList',\n\n /** One word, or an ordered list of words: a chart colour is one colour for the series or one for each point. */\n StringOrList: 'stringOrList',\n\n /** One word, number or flag - a value whose type the author chooses, such as the selected value of a control whose options carry any of them. */\n Scalar: 'scalar',\n\n /** A record of words, numbers and flags under names the author chooses. */\n StringMap: 'stringMap',\n} as const;\n\nexport type PropertyEditorKind = (typeof PropertyEditorKind)[keyof typeof PropertyEditorKind];\n"],"names":["PropertyEditorKind","StringList","NumberList","StringOrList","Scalar","StringMap"],"mappings":";;AAAA;AACA;AAEA;;;;;;UAOaA,kBAAAA,GAAqB;AAC9B,qCACAC,UAAAA,EAAY,YAAA;AAEZ,uCACAC,UAAAA,EAAY,YAAA;AAEZ,qHACAC,YAAAA,EAAc,cAAA;AAEd,sJACAC,MAAAA,EAAQ,QAAA;AAER,gFACAC,SAAAA,EAAW;AACf;;"}
1
+ {"version":3,"file":"PropertyEditorKind.js","sources":["../../../descriptors/PropertyEditorKind.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * The editor ids Studio's property-editor registry resolves (spec section 8). A property names one in `editorKind`; a host that\n * does not know the id falls back to the default editor for `valueType`, and a package may name ids of its own (they are strings).\n * This vocabulary defines only the ids and, in {@link PropertyEditorOptions}, their parameters - the editors themselves belong to the host.\n *\n * It starts with the editors for values that have no fields to describe, so a host can edit them without asking for JSON text.\n *\n * A list of plain values is a `json` property - Scene keeps the array exactly as authored - whose `editorKind` says what\n * its entries are. A record whose keys are the author's own (a row of data, keyed by column) is an `object` property\n * with no `properties` and the `stringMap` kind. A host that does not know a kind falls back to its default editor.\n */\nexport const PropertyEditorKind = {\n /** An ordered list of words. */\n StringList: 'stringList',\n\n /** An ordered list of numbers. */\n NumberList: 'numberList',\n\n /** One word, or an ordered list of words: a chart colour is one colour for the series or one for each point. */\n StringOrList: 'stringOrList',\n\n /** One word, number or flag - a value whose type the author chooses, such as the selected value of a control whose options carry any of them. */\n Scalar: 'scalar',\n\n /** A record of words, numbers and flags under names the author chooses. */\n StringMap: 'stringMap',\n\n /** A single line of text; `editorOptions.multiline` makes it a box, `editorOptions.placeholder` hints it. */\n Text: 'text',\n\n /** A number; `constraints.minimum`/`maximum` and `editorOptions.step`/`unit` shape it. */\n Number: 'number',\n\n /** A switch with a label. */\n Boolean: 'boolean',\n\n /** Up to four choices as segmented chips. */\n Enum: 'enum',\n\n /** Any number of choices as a dropdown with a filter. */\n Select: 'select',\n\n /** A theme token first, a custom colour second. */\n Color: 'color',\n\n /** An icon from a searchable grid. */\n Icon: 'icon',\n\n /** A list of simple items: add, remove, reorder rows. */\n List: 'list',\n\n /** The id of another model element, from a searchable dropdown restricted by `editorOptions.reference`. */\n Reference: 'reference',\n\n /** The target of a navigation item: a Module > Feature tree, shown as a breadcrumb when closed. */\n NavigationTarget: 'navigationTarget',\n\n /** One of the slots of the effective template, with a mini diagram of its position. */\n RenderingSlot: 'renderingSlot',\n\n /** A slice from the slice tree; `editorOptions.kinds` (for example `['StateChange']`) filters, the rest are listed disabled with a reason. */\n Slice: 'slice',\n\n /** How a region relates to what it inherits: `inherit`, `extend` or `override`, as a three-way control. */\n InheritanceMode: 'inheritanceMode',\n\n /** A reference to a template, chosen through the template picker. */\n Template: 'template',\n\n /** A reference to a sample data pack. */\n SampleData: 'sampleData',\n\n /** A field of the shape a component is bound to, typed by `editorOptions.fieldKinds`. */\n Field: 'field',\n\n /** The columns of a table: rows of `{ field, header, width, align, format }`. */\n ColumnList: 'columnList',\n} as const;\n\nexport type PropertyEditorKind = (typeof PropertyEditorKind)[keyof typeof PropertyEditorKind];\n"],"names":["PropertyEditorKind","StringList","NumberList","StringOrList","Scalar","StringMap","Text","Number","Boolean","Enum","Select","Color","Icon","List","Reference","NavigationTarget","RenderingSlot","Slice","InheritanceMode","Template","SampleData","Field","ColumnList"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;;;UAWaA,kBAAAA,GAAqB;AAC9B,qCACAC,UAAAA,EAAY,YAAA;AAEZ,uCACAC,UAAAA,EAAY,YAAA;AAEZ,qHACAC,YAAAA,EAAc,cAAA;AAEd,sJACAC,MAAAA,EAAQ,QAAA;AAER,gFACAC,SAAAA,EAAW,WAAA;AAEX,kHACAC,IAAAA,EAAM,MAAA;AAEN,+FACAC,MAAAA,EAAQ,QAAA;AAER,kCACAC,OAAAA,EAAS,SAAA;AAET,kDACAC,IAAAA,EAAM,MAAA;AAEN,8DACAC,MAAAA,EAAQ,QAAA;AAER,wDACAC,KAAAA,EAAO,OAAA;AAEP,2CACAC,IAAAA,EAAM,MAAA;AAEN,8DACAC,IAAAA,EAAM,MAAA;AAEN,gHACAC,SAAAA,EAAW,WAAA;AAEX,wGACAC,gBAAAA,EAAkB,kBAAA;AAElB,4FACAC,aAAAA,EAAe,eAAA;AAEf,mJACAC,KAAAA,EAAO,OAAA;AAEP,gHACAC,eAAAA,EAAiB,iBAAA;AAEjB,0EACAC,QAAAA,EAAU,UAAA;AAEV,8CACAC,UAAAA,EAAY,YAAA;AAEZ,8FACAC,KAAAA,EAAO,OAAA;AAEP,sFACAC,UAAAA,EAAY;AAChB;;"}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * What a `reference` editor offers: the model elements of one kind, narrowed by a named rule.
7
+ */ const ReferenceFilterDescriptorPropertyNames = [
8
+ 'target',
9
+ 'kinds',
10
+ 'predicate'
11
+ ];
12
+ const PropertyEditorOptionsPropertyNames = [
13
+ 'multiline',
14
+ 'placeholder',
15
+ 'unit',
16
+ 'step',
17
+ 'kinds',
18
+ 'reference',
19
+ 'fieldKinds',
20
+ 'tokensOnly'
21
+ ];
22
+
23
+ exports.PropertyEditorOptionsPropertyNames = PropertyEditorOptionsPropertyNames;
24
+ exports.ReferenceFilterDescriptorPropertyNames = ReferenceFilterDescriptorPropertyNames;
25
+ //# sourceMappingURL=PropertyEditorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyEditorOptions.js","sources":["../../../descriptors/PropertyEditorOptions.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * What a `reference` editor offers: the model elements of one kind, narrowed by a named rule.\n */\nexport interface ReferenceFilterDescriptor {\n /** The kind of model element referenced: `screen`, `slice`, `template`, `shape`, `field` ... A host maps it to what it can list. */\n target: string;\n\n /** Narrows the target to these kinds (a slice is a `StateChange`, a `ReadModel` ...). Absent means every kind. */\n kinds?: string[];\n\n /** Names the rule that decides which candidates are offered, interpreted by the host - like `availability` of a design-time action. */\n predicate?: string;\n}\n\n/**\n * The parameters of a named editor, alongside `PropertyDescriptor.editorKind`: the bits a generic editor needs that are not a value\n * constraint. Every field is optional and only the ones an editor documents are read.\n */\nexport interface PropertyEditorOptions {\n /** `text`: a multi-line box instead of a single line. */\n multiline?: boolean;\n\n /** `text`: the hint shown while empty. */\n placeholder?: string;\n\n /** `number`: the unit shown after the value (`px`, `%`, `ms`). */\n unit?: string;\n\n /** `number`: the increment of a stepper. The range is `constraints.minimum` and `constraints.maximum`. */\n step?: number;\n\n /** `slice`: the slice kinds that can be chosen (`['StateChange']`); others are listed disabled with a reason. */\n kinds?: string[];\n\n /** `reference`: what can be referenced. Required by the `reference` editor. */\n reference?: ReferenceFilterDescriptor;\n\n /** `field`: the kinds of field offered (`string`, `number`, `boolean` ...). Absent means any. */\n fieldKinds?: string[];\n\n /** `color`: only theme tokens, no custom colour. */\n tokensOnly?: boolean;\n}\n\nexport const ReferenceFilterDescriptorPropertyNames: (keyof ReferenceFilterDescriptor)[] = ['target', 'kinds', 'predicate'];\nexport const PropertyEditorOptionsPropertyNames: (keyof PropertyEditorOptions)[] = [\n 'multiline', 'placeholder', 'unit', 'step', 'kinds', 'reference', 'fieldKinds', 'tokensOnly',\n];\n"],"names":["ReferenceFilterDescriptorPropertyNames","PropertyEditorOptionsPropertyNames"],"mappings":";;AAAA;AACA;AAEA;;UA4CaA,sCAAAA,GAA8E;AAAC,IAAA,QAAA;AAAU,IAAA,OAAA;AAAS,IAAA;;MAClGC,kCAAAA,GAAsE;AAC/E,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA,MAAA;AAAQ,IAAA,MAAA;AAAQ,IAAA,OAAA;AAAS,IAAA,WAAA;AAAa,IAAA,YAAA;AAAc,IAAA;;;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The icon library the built-in components' icons come from: the Lucide library package a Cratis host ships. A component's icon is an
7
+ * ordinary {@link IconReference}, so a host without that library shows the component's badge instead (see the component picker) and
8
+ * the icon diagnostics report it like any other icon.
9
+ */ const componentIconLibrary = 'Cratis.Icons.Lucide';
10
+ /** The icon with this key in {@link componentIconLibrary}. */ function componentIcon(key) {
11
+ return {
12
+ library: componentIconLibrary,
13
+ key
14
+ };
15
+ }
16
+
17
+ exports.componentIcon = componentIcon;
18
+ exports.componentIconLibrary = componentIconLibrary;
19
+ //# sourceMappingURL=componentIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentIcon.js","sources":["../../../descriptors/componentIcon.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IconReference } from '../icons';\n\n/**\n * The icon library the built-in components' icons come from: the Lucide library package a Cratis host ships. A component's icon is an\n * ordinary {@link IconReference}, so a host without that library shows the component's badge instead (see the component picker) and\n * the icon diagnostics report it like any other icon.\n */\nexport const componentIconLibrary = 'Cratis.Icons.Lucide';\n\n/** The icon with this key in {@link componentIconLibrary}. */\nexport function componentIcon(key: string): IconReference {\n return { library: componentIconLibrary, key };\n}\n"],"names":["componentIconLibrary","componentIcon","key","library"],"mappings":";;AAAA;AACA;AAIA;;;;IAKO,MAAMA,oBAAAA,GAAuB;AAEpC,+DACO,SAASC,aAAAA,CAAcC,GAAW,EAAA;IACrC,OAAO;QAAEC,OAAAA,EAASH,oBAAAA;AAAsBE,QAAAA;AAAI,KAAA;AAChD;;;"}
@@ -57,6 +57,11 @@
57
57
  DiagnosticCode["IncompatibleIconLibrary"] = "incompatibleIconLibrary";
58
58
  DiagnosticCode["IconCatalogUnavailable"] = "iconCatalogUnavailable";
59
59
  DiagnosticCode["IconNotVerified"] = "iconNotVerified";
60
+ // Component metadata
61
+ DiagnosticCode["ComponentCategoryMissing"] = "componentCategoryMissing";
62
+ DiagnosticCode["ComponentCategoryUnknown"] = "componentCategoryUnknown";
63
+ DiagnosticCode["ComponentDesignModeInvalid"] = "componentDesignModeInvalid";
64
+ DiagnosticCode["PropertyEditorOptionsInvalid"] = "propertyEditorOptionsInvalid";
60
65
  return DiagnosticCode;
61
66
  }({});
62
67