spell-ui 0.8.16 → 0.8.17

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 (41) hide show
  1. package/dist/{UIInput-B3K0w4ow.js → UIInput-8s1aiaw1.js} +2 -2
  2. package/dist/UIInput-8s1aiaw1.js.map +1 -0
  3. package/dist/{UIRuntime-DxC1O7ON.js → UIRuntime-BaokNnwk.js} +8 -4
  4. package/dist/UIRuntime-BaokNnwk.js.map +1 -0
  5. package/dist/_spell-element/UIComponent.d.ts +7 -0
  6. package/dist/_spell-element/elements.types.d.ts +6 -0
  7. package/dist/_spell-element/vocabulary.types.d.ts +22 -0
  8. package/dist/_util/dom.d.ts +1 -1
  9. package/dist/components/ui-graph/UIGraph.d.ts +17 -0
  10. package/dist/components/ui-graph/UIGraph.en.d.ts +17 -0
  11. package/dist/components/ui-graph/UIGraph.es.d.ts +6 -0
  12. package/dist/components/ui-modal/ChoiceRows.d.ts +61 -0
  13. package/dist/components/ui-modal/ModalDialogs.d.ts +15 -1
  14. package/dist/components/ui-modal/UIModal.d.ts +6 -2
  15. package/dist/components/ui-modal/UIModal.en.d.ts +6 -2
  16. package/dist/components/ui-modal/UIModal.es.d.ts +1 -0
  17. package/dist/components/ui-tree/UITree.d.ts +5 -0
  18. package/dist/components/ui-tree/UITree.en.d.ts +5 -0
  19. package/dist/components/ui-tree/UITree.es.d.ts +3 -0
  20. package/dist/{components.es-eyezTRd7.js → components.es-jY2nBwuP.js} +11 -3
  21. package/dist/components.es-jY2nBwuP.js.map +1 -0
  22. package/dist/core.js +456 -431
  23. package/dist/core.js.map +1 -1
  24. package/dist/runtime/Modals.d.ts +7 -2
  25. package/dist/runtime/Styles.d.ts +7 -1
  26. package/dist/runtime/runtime.types.d.ts +26 -1
  27. package/dist/ui-calendar.js +1 -1
  28. package/dist/ui-graph.js +22 -0
  29. package/dist/ui-graph.js.map +1 -1
  30. package/dist/ui-input.js +1 -1
  31. package/dist/ui-modal.js +183 -97
  32. package/dist/ui-modal.js.map +1 -1
  33. package/dist/ui-root.js +1 -1
  34. package/dist/ui-search.js +1 -1
  35. package/dist/ui-tree.js +6 -1
  36. package/dist/ui-tree.js.map +1 -1
  37. package/dist/vocabulary/hooks.generated.d.ts +7 -0
  38. package/package.json +1 -1
  39. package/dist/UIInput-B3K0w4ow.js.map +0 -1
  40. package/dist/UIRuntime-DxC1O7ON.js.map +0 -1
  41. package/dist/components.es-eyezTRd7.js.map +0 -1
@@ -664,6 +664,13 @@ export declare abstract class UIComponent<V extends E.ComponentVocabulary = E.Co
664
664
  * - throws a `TypeError` when a tag defined early no longer matches its root's catalog (`DOMElement.attach()`)
665
665
  */
666
666
  static define(this: E.UIComponentClass, tag?: string, dictionary?: E.Dictionary): CustomElementConstructor | undefined;
667
+ /**
668
+ * Give `Class`'s vocabulary an empty list for each list it leaves out: `events`, `slots`, `parts`, `states`, `texts`.
669
+ * - So a subclass's small vocabulary, written by hand or in JavaScript, defines (epic `from-jarvis` P11):
670
+ * one with no `slots` crashed `Vocabulary.resolve()` ("vocabulary.slots is not iterable").
671
+ * - SIDE EFFECT: fills them in on the vocabulary itself; a frozen one is copied onto `Class` instead.
672
+ */
673
+ private static completeVocabulary;
667
674
  /**
668
675
  * What the DOM element class of `definition`'s tag carries, for component class `Class`:
669
676
  * its definition, shadow root options, whether it's a form control, and how to build its component.
@@ -127,6 +127,12 @@ export type ComponentRegistry = {
127
127
  * `UIComponent.registry.definitions.get(child.localName)?.vocabulary.noun`.
128
128
  */
129
129
  readonly definitions: Map<string, E.ElementDefinition>;
130
+ /**
131
+ * The component class of every defined tag, by tag: `UITree` for `ui-tree`.
132
+ * - What a class built on a tag's component starts from, knowing only its tag:
133
+ * a Spell type built on a Spell UI element (the app's `SpellElement`, epic `from-jarvis` P11).
134
+ */
135
+ readonly components: Map<string, UIComponentClass>;
130
136
  /** The vocabularies already handed to the runtime (`UIComponent.register()`), so each is handed over once. */
131
137
  readonly vocabularies: WeakSet<E.ComponentVocabulary>;
132
138
  };
@@ -271,6 +271,24 @@ export type TextSpec = {
271
271
  /** Where it shows, for translators and docs. */
272
272
  description?: string;
273
273
  };
274
+ /**
275
+ * A method a subclass overrides to change how the element draws, with the words Spell says it in
276
+ * (epic `from-jarvis` P11, Q11): `<ui-tree>`'s `rowClass(item)`, `to give the row class of (an item)`.
277
+ * - A Spell type built on the element (`a "netlist column" is a ui tree view`) overrides it with a `to` line in
278
+ * those words, as a card overrides `to draw its front`; its element calls the type's method in its place.
279
+ * - A translation gives its own words (`ComponentDictionary.hooks`).
280
+ */
281
+ export type HookSpec = {
282
+ /** The method's name, as the component class has it, e.g. `rowClass`. */
283
+ name: string;
284
+ /**
285
+ * Its words, as a `to` line says them, each argument in brackets with its type:
286
+ * `give the row class of (an item)`.
287
+ */
288
+ words: string;
289
+ /** What it gives back, and when it's called, for docs. */
290
+ description?: string;
291
+ };
274
292
  /**
275
293
  * Everything a component names -- the contents of `UI<Name>.en.ts`.
276
294
  * - Write it as `export const cardVocabulary = { ... } as const satisfies ComponentVocabulary`,
@@ -320,6 +338,8 @@ export type ComponentVocabulary = {
320
338
  states: readonly StateSpec[];
321
339
  /** Text it shows people (`UI.i18n`). */
322
340
  texts: readonly TextSpec[];
341
+ /** The methods a subclass overrides, with their Spell words (`HookSpec`); none: left out. */
342
+ hooks?: readonly HookSpec[];
323
343
  /**
324
344
  * Nouns of the generic content parts this component styles by context, e.g. card:
325
345
  * `header`, `meta`, `description`, `content`, `extra`.
@@ -543,6 +563,8 @@ export type ComponentDictionary = {
543
563
  aka?: readonly string[];
544
564
  /** Text key => text people read, for this component only (`UI.i18n`), e.g. `{ loading: "Cargando…" }`. */
545
565
  texts?: NameMap;
566
+ /** Hook name => its words in this language (`HookSpec`), e.g. `{ rowClass: "dar la clase de fila de (un elemento)" }`. */
567
+ hooks?: NameMap;
546
568
  };
547
569
  /**
548
570
  * One tag's names in one language, in a file of its own beside its vocabulary: `UIButton.es.ts`.
@@ -36,7 +36,7 @@ export declare function nextFrame(count?: number): Promise<number>;
36
36
  * The first of `properties` set on `element`, as a CSS time in seconds: `800ms` => `0.8`, `1.5s` => `1.5`.
37
37
  * - `undefined` when none is set, or what's set isn't a time.
38
38
  * - The wait a hover reads, as it starts: `cssSecondsFor(target, "--ui-tooltip-delay", "--ui-hover-delay")`.
39
- * - Read live, each call: so a page that changes the property (Settings… › Popup delay) is followed at once.
39
+ * - Read live, each call: so a page that changes the property (Settings… › "Delay before showing help") is followed at once.
40
40
  */
41
41
  export declare function cssSecondsFor(element: Element, ...properties: string[]): number | undefined;
42
42
  /**
@@ -173,6 +173,23 @@ export declare class UIGraph extends E.UIComponent<typeof graphVocabulary> {
173
173
  readonly text: "Loading …";
174
174
  readonly description: "A node whose children are loading.";
175
175
  }];
176
+ readonly hooks: readonly [{
177
+ readonly name: "nodeLabel";
178
+ readonly words: "give the label of (a node)";
179
+ readonly description: "A node's text; by default its `label`, else its id.";
180
+ }, {
181
+ readonly name: "nodeClass";
182
+ readonly words: "give the class of (a node)";
183
+ readonly description: "Extra class names on a node, for the subclass's own sheet.";
184
+ }, {
185
+ readonly name: "edgeLabel";
186
+ readonly words: "give the label of (an edge)";
187
+ readonly description: "An edge's text, at its middle; none: no text.";
188
+ }, {
189
+ readonly name: "edgeClass";
190
+ readonly words: "give the class of (an edge)";
191
+ readonly description: "Extra class names on an edge, for the subclass's own sheet.";
192
+ }];
176
193
  };
177
194
  static elementSetup: {
178
195
  styleSheets: {
@@ -134,4 +134,21 @@ export declare const graphVocabulary: {
134
134
  readonly text: "Loading …";
135
135
  readonly description: "A node whose children are loading.";
136
136
  }];
137
+ readonly hooks: readonly [{
138
+ readonly name: "nodeLabel";
139
+ readonly words: "give the label of (a node)";
140
+ readonly description: "A node's text; by default its `label`, else its id.";
141
+ }, {
142
+ readonly name: "nodeClass";
143
+ readonly words: "give the class of (a node)";
144
+ readonly description: "Extra class names on a node, for the subclass's own sheet.";
145
+ }, {
146
+ readonly name: "edgeLabel";
147
+ readonly words: "give the label of (an edge)";
148
+ readonly description: "An edge's text, at its middle; none: no text.";
149
+ }, {
150
+ readonly name: "edgeClass";
151
+ readonly words: "give the class of (an edge)";
152
+ readonly description: "Extra class names on an edge, for the subclass's own sheet.";
153
+ }];
137
154
  };
@@ -45,4 +45,10 @@ export declare const graphEs: {
45
45
  readonly graphTop: "Inicio";
46
46
  readonly graphLoading: "Cargando …";
47
47
  };
48
+ readonly hooks: {
49
+ readonly nodeLabel: "dar la etiqueta de (un nodo)";
50
+ readonly nodeClass: "dar la clase de (un nodo)";
51
+ readonly edgeLabel: "dar la etiqueta de (una arista)";
52
+ readonly edgeClass: "dar la clase de (una arista)";
53
+ };
48
54
  };
@@ -0,0 +1,61 @@
1
+ import { E } from 'spell/ui/core';
2
+ /****************
3
+ * ### `ChoiceRows`
4
+ * The rows of `UI.modals.choose()`'s dialog, and which of them are picked (epic `language` P66).
5
+ * - Up to `BUTTON_ROWS` rows: a `<ui-button>` each, one under another.
6
+ * - More: a `<ui-list selection>` of `<ui-item>`s that scrolls, with a search box above it, which hides the rows
7
+ * whose words don't hold what's typed.
8
+ * - `shown`: how many rows show before the rows scroll; default every button, or `LIST_ROWS` of a list.
9
+ * - One: a row picks itself (`onPicked()`), and the dialog closes.
10
+ * - Several: each row turns on and off; `onCountChanged()` says whether OK may pick them (`fits`).
11
+ * - A row with a `color`: a `<ui-color-chip>` before its words, read-only, so the row around it is what's picked;
12
+ * `ModalDialogs.choose()` imports the chip's family first.
13
+ * - Plain DOM, built with `createElement` / `textContent`, as `ModalDialogs` is: never `innerHTML` with caller text.
14
+ * - Other families' tags are found by class noun (`tagFor`), as `ModalDialogs` finds them.
15
+ ****************/
16
+ export declare class ChoiceRows {
17
+ /** what the dialog holds: the rows, and the search box above a long list */
18
+ readonly element: HTMLElement;
19
+ /** pick several */
20
+ readonly several: boolean;
21
+ /** the rows picked, by position */
22
+ readonly picked: Set<number>;
23
+ /** a row picked itself: one, never several */
24
+ onPicked: () => void;
25
+ /** several: the rows picked changed */
26
+ onCountChanged: () => void;
27
+ private readonly document;
28
+ private readonly least;
29
+ private readonly most;
30
+ constructor({ document, options, tagFor }: ChoiceRowsProps);
31
+ /** May OK pick the rows picked now? Several: as many as `least` to `most`. */
32
+ get fits(): boolean;
33
+ /** The rows picked, by position, in the order they show. */
34
+ get positions(): number[];
35
+ /** A `<ui-button>` per row, one under another; a `toggle` button each, for several. */
36
+ private drawButtons;
37
+ /** A search box, then a `<ui-list selection>` of the rows, `shown` of them tall. */
38
+ private drawList;
39
+ /** A box `shown` rows of `rowHeight` tall, that scrolls past that; none: as tall as its rows. */
40
+ private scroller;
41
+ /** A row's words, and its color's chip before them. */
42
+ private words;
43
+ /** One: `position` is picked, and the dialog closes. */
44
+ private pick;
45
+ /** Several: `position` turned on or off. */
46
+ private turn;
47
+ }
48
+ /** What `ChoiceRows` is made from. */
49
+ export type ChoiceRowsProps = {
50
+ /** page to build in */
51
+ document: Document;
52
+ /** the dialog's options: its rows, and how many may be picked */
53
+ options: E.ChooseModalOptions;
54
+ /** the registered tag of a class noun: `ModalDialogs.tagFor()` */
55
+ tagFor: TagFor;
56
+ };
57
+ /** The registered tag of a class noun, `button` => `ui-button`. */
58
+ type TagFor = (noun: string) => string;
59
+ /** The most rows drawn as buttons: past it, a list with a search box (Q75). */
60
+ export declare const BUTTON_ROWS = 20;
61
+ export {};
@@ -1,7 +1,8 @@
1
1
  import { E } from 'spell/ui/core';
2
2
  /****************
3
3
  * ### `ModalDialogs`
4
- * The dialogs behind `UI.modals.confirm()` / `alert()` / `prompt()` (Fomantic's `$.modal('confirm', …)`):
4
+ * The dialogs behind `UI.modals.confirm()` / `alert()` / `prompt()` (Fomantic's `$.modal('confirm', …)`),
5
+ * and `choose()`'s pick from a list (its rows: `ChoiceRows`):
5
6
  * a `<ui-modal>` built for the call, appended to `<body>`, shown (`visible`), and removed once hidden.
6
7
  *
7
8
  * - Markup: `<ui-modal size="tiny" closedby="closerequest" closable heading="title">` holding
@@ -35,6 +36,15 @@ export declare class ModalDialogs implements E.ModalProvider {
35
36
  alert(options: E.ModalOptions): Promise<void>;
36
37
  /** Ask for one line of text: resolves with it on approve, `undefined` on deny or Escape. */
37
38
  prompt(options: E.ModalOptions): Promise<string | undefined>;
39
+ /**
40
+ * Ask the person to pick from `options.rows`: resolves with the positions picked, `undefined` on deny or Escape
41
+ * (epic `language` P66).
42
+ * - One: a row picks itself, and the dialog closes; no OK button.
43
+ * - Several: each row turns on and off; OK stays off until as many as `least` to `most` are on.
44
+ * - More than `BUTTON_ROWS` rows: the list family is imported first, for its `<ui-list>`.
45
+ * - A row with a color: the theme editor's family is imported first, for its `<ui-color-chip>`.
46
+ */
47
+ choose(options: E.ChooseModalOptions): Promise<number[] | undefined>;
38
48
  /**
39
49
  * Build, open and await one dialog; `result()` turns "approved?" and the input's value into the answer.
40
50
  * - SIDE EFFECT: a `<ui-modal>` in `<body>` until it has hidden.
@@ -46,6 +56,10 @@ export declare class ModalDialogs implements E.ModalProvider {
46
56
  * - Plain text opens at once, in the same task as the call: callers and tests find the dialog straight away.
47
57
  */
48
58
  private open;
59
+ /**
60
+ * SIDE EFFECT: `rows` answer `modal`: a row picked hides it; several keep `approve` off until the count fits.
61
+ */
62
+ private answerWith;
49
63
  /**
50
64
  * The message as a paragraph, a `\n` in it a line break.
51
65
  * - `size`: its words in a `<span>` of that text size, so the paragraph's own margins stay the dialog's
@@ -149,11 +149,15 @@ export declare class UIModal extends DialogComponent<Vocabulary> {
149
149
  }, {
150
150
  readonly key: "ok";
151
151
  readonly text: "OK";
152
- readonly description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()`.";
152
+ readonly description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()`, and `choose()` picking several.";
153
153
  }, {
154
154
  readonly key: "cancel";
155
155
  readonly text: "Cancel";
156
- readonly description: "Deny button of `UI.modals.confirm()` / `prompt()`.";
156
+ readonly description: "Deny button of `UI.modals.confirm()` / `prompt()` / `choose()`.";
157
+ }, {
158
+ readonly key: "search";
159
+ readonly text: "Search";
160
+ readonly description: "Search box above a long list of `UI.modals.choose()`.";
157
161
  }];
158
162
  readonly ownsParts: readonly ["header", "content", "description", "actions"];
159
163
  };
@@ -152,11 +152,15 @@ export declare const modalVocabulary: {
152
152
  }, {
153
153
  readonly key: "ok";
154
154
  readonly text: "OK";
155
- readonly description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()`.";
155
+ readonly description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()`, and `choose()` picking several.";
156
156
  }, {
157
157
  readonly key: "cancel";
158
158
  readonly text: "Cancel";
159
- readonly description: "Deny button of `UI.modals.confirm()` / `prompt()`.";
159
+ readonly description: "Deny button of `UI.modals.confirm()` / `prompt()` / `choose()`.";
160
+ }, {
161
+ readonly key: "search";
162
+ readonly text: "Search";
163
+ readonly description: "Search box above a long list of `UI.modals.choose()`.";
160
164
  }];
161
165
  readonly ownsParts: readonly ["header", "content", "description", "actions"];
162
166
  };
@@ -21,5 +21,6 @@ export declare const modalEs: {
21
21
  readonly close: "Cerrar";
22
22
  readonly ok: "Aceptar";
23
23
  readonly cancel: "Cancelar";
24
+ readonly search: "Buscar";
24
25
  };
25
26
  };
@@ -292,6 +292,11 @@ export declare class UITree extends E.UIComponent<typeof treeVocabulary> {
292
292
  readonly text: "Stopped looking after {count} rows";
293
293
  readonly description: "`appearance=\"columns\"` with a `filter`: the look through the tree went through that many rows, and stopped.";
294
294
  }];
295
+ readonly hooks: readonly [{
296
+ readonly name: "rowClass";
297
+ readonly words: "give the row class of (an item)";
298
+ readonly description: string;
299
+ }];
295
300
  };
296
301
  static elementSetup: Partial<E.ElementSetup>;
297
302
  /** The anchor of a Shift range. */
@@ -212,4 +212,9 @@ export declare const treeVocabulary: {
212
212
  readonly text: "Stopped looking after {count} rows";
213
213
  readonly description: "`appearance=\"columns\"` with a `filter`: the look through the tree went through that many rows, and stopped.";
214
214
  }];
215
+ readonly hooks: readonly [{
216
+ readonly name: "rowClass";
217
+ readonly words: "give the row class of (an item)";
218
+ readonly description: string;
219
+ }];
215
220
  };
@@ -60,4 +60,7 @@ export declare const treeEs: {
60
60
  readonly moreMatches: "{count} más, sin listar";
61
61
  readonly stoppedLooking: "Dejó de buscar tras {count} filas";
62
62
  };
63
+ readonly hooks: {
64
+ readonly rowClass: "dar la clase de fila de (un elemento)";
65
+ };
63
66
  };
@@ -1005,7 +1005,8 @@ var te = {
1005
1005
  texts: {
1006
1006
  close: "Cerrar",
1007
1007
  ok: "Aceptar",
1008
- cancel: "Cancelar"
1008
+ cancel: "Cancelar",
1009
+ search: "Buscar"
1009
1010
  }
1010
1011
  }, ae = {
1011
1012
  lang: "es",
@@ -1154,7 +1155,8 @@ var te = {
1154
1155
  lookingElsewhere: "Buscando en el árbol",
1155
1156
  moreMatches: "{count} más, sin listar",
1156
1157
  stoppedLooking: "Dejó de buscar tras {count} filas"
1157
- }
1158
+ },
1159
+ hooks: { rowClass: "dar la clase de fila de (un elemento)" }
1158
1160
  }, ue = {
1159
1161
  lang: "es",
1160
1162
  tag: "ui-site-nav",
@@ -3826,6 +3828,12 @@ var te = {
3826
3828
  graphFit: "Ajustar",
3827
3829
  graphTop: "Inicio",
3828
3830
  graphLoading: "Cargando …"
3831
+ },
3832
+ hooks: {
3833
+ nodeLabel: "dar la etiqueta de (un nodo)",
3834
+ nodeClass: "dar la clase de (un nodo)",
3835
+ edgeLabel: "dar la etiqueta de (una arista)",
3836
+ edgeClass: "dar la clase de (una arista)"
3829
3837
  }
3830
3838
  },
3831
3839
  {
@@ -3875,4 +3883,4 @@ var te = {
3875
3883
  ]);
3876
3884
  export { mt as es };
3877
3885
 
3878
- //# sourceMappingURL=components.es-eyezTRd7.js.map
3886
+ //# sourceMappingURL=components.es-jY2nBwuP.js.map