@mosaicajs/components 0.2.0 → 0.4.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 (52) hide show
  1. package/README.md +2 -0
  2. package/dist/aggregate.d.ts +4 -10
  3. package/dist/aggregate.js +7 -13
  4. package/dist/artifact-card.d.ts +21 -7
  5. package/dist/artifact-card.js +136 -79
  6. package/dist/base.d.ts +44 -5
  7. package/dist/base.js +54 -5
  8. package/dist/cluster-filter.d.ts +29 -25
  9. package/dist/cluster-filter.js +123 -106
  10. package/dist/colour-editor.d.ts +15 -4
  11. package/dist/colour-editor.js +107 -34
  12. package/dist/colour-picker.d.ts +12 -5
  13. package/dist/colour-picker.js +119 -32
  14. package/dist/display.js +77 -9
  15. package/dist/events.d.ts +21 -7
  16. package/dist/explorer.d.ts +118 -37
  17. package/dist/explorer.js +487 -212
  18. package/dist/field-card.d.ts +304 -48
  19. package/dist/field-card.js +1364 -244
  20. package/dist/filter-panel.d.ts +54 -10
  21. package/dist/filter-panel.js +242 -42
  22. package/dist/filter.d.ts +22 -4
  23. package/dist/filter.js +113 -34
  24. package/dist/hierarchy.d.ts +68 -45
  25. package/dist/hierarchy.js +320 -243
  26. package/dist/item-card.d.ts +62 -14
  27. package/dist/item-card.js +310 -110
  28. package/dist/key-picker.d.ts +2 -1
  29. package/dist/key-picker.js +4 -3
  30. package/dist/layer-picker.d.ts +4 -2
  31. package/dist/layer-picker.js +16 -7
  32. package/dist/lineage.d.ts +132 -0
  33. package/dist/lineage.js +307 -0
  34. package/dist/map.d.ts +135 -24
  35. package/dist/map.js +387 -117
  36. package/dist/mosaica-components.js +1848 -832
  37. package/dist/mosaica-components.js.sri +1 -1
  38. package/dist/mosaica-components.json +2 -2
  39. package/dist/parts.d.ts +4 -4
  40. package/dist/parts.js +18 -4
  41. package/dist/paths.d.ts +34 -12
  42. package/dist/paths.js +84 -46
  43. package/dist/selection.d.ts +22 -3
  44. package/dist/selection.js +125 -59
  45. package/dist/states.d.ts +72 -0
  46. package/dist/states.js +135 -26
  47. package/dist/status.d.ts +63 -5
  48. package/dist/status.js +215 -36
  49. package/dist/tokens.d.ts +8 -4
  50. package/dist/tokens.js +144 -14
  51. package/dist/view-picker.js +5 -0
  52. package/package.json +4 -3
@@ -9,14 +9,25 @@ import { MosaicaElement, type PickOutcome } from './base.js';
9
9
  *
10
10
  * The headline is the `title-field` field, or the item's `mosaica_id` when that field is unset or
11
11
  * empty. To render a field your own way, as a link for example, put an element in its
12
- * `field-<name>` slot.
12
+ * `field-<name>` slot. The card is headed "Item" for a screen reader, with the headline a heading
13
+ * under it.
14
+ *
15
+ * A value over 60 characters is kept to six lines, with a Show more button under it where that
16
+ * cuts it short. A `compact` card also keeps its headline to three lines and its subtitle to two,
17
+ * and its Show all button shows every field and all of each.
18
+ *
19
+ * A field named in `image-fields` whose value is an `http:` or `https:` address, or a path
20
+ * resolved against the page, is drawn as the image at that address, across the card's width. The viewer's browser loads it from the host
21
+ * that serves it, without a referrer. Its alternative text is the item's `title-field` value, or
22
+ * the field's name where the item has none. A value that is not such an address, and an image that
23
+ * does not load, are shown as text.
13
24
  *
14
25
  * The Open button appears only when you set `open-url` or `open`. `open-url` is a link template
15
26
  * such as `https://www.geonames.org/{geonameid}`, in which each `{name}` is replaced by the item's
16
27
  * value for that field. Because the values are URL-encoded, a template cannot open an address that
17
28
  * a field already holds, so set `open` to a function for that. An item gets no Open button when it
18
- * has no value for a field the template names. A function in `open` is called with the item's
19
- * `mosaica_id` and fields, and it takes precedence over `open-url`.
29
+ * has no value for a field the template names. The link opens in a new tab. A function in `open`
30
+ * is called with the item's `mosaica_id` and fields, and it takes precedence over `open-url`.
20
31
  *
21
32
  * @summary A card showing an item's fields, with an optional Open button.
22
33
  * @tagname mosaica-item-card
@@ -31,22 +42,26 @@ import { MosaicaElement, type PickOutcome } from './base.js';
31
42
  * @csspart title - The header row: the headline or the state, and the close button.
32
43
  * @csspart close - The close button.
33
44
  * @csspart state - The state line, with `data-state`: `shown`, `empty` (no item, or a click that
34
- * found nothing), `refused` or `detached`.
45
+ * found nothing), `refused` or `detached`. It is inside a `role="status"` region.
35
46
  * @csspart refusal - The words "Item unavailable", with `data-code` set to the refusal's code if
36
47
  * the server refused the record. For a broken pick, the details are in the map's `lastPick`.
37
48
  * @csspart reason - The server's reason for refusing the record, under "Item unavailable".
38
- * @csspart headline - The headline, with `data-name` set to the field it shows.
49
+ * @csspart headline - The headline, an `<h3>`, with `data-name` set to the field it shows.
39
50
  * @csspart subtitle - The `subtitle-field` value under the headline, when `compact` is set.
40
51
  * @csspart show-all - The "Show all N fields" button, when `compact` is set, with `aria-expanded`.
41
- * @csspart view-chip - One view the item is in, with `data-view` and `aria-current` on the current
42
- * view.
52
+ * It reads "Show all" where every field is shown and only text is cut short.
53
+ * @csspart view-chip - One view the item is in, with `data-view`, and `aria-current` and a bar
54
+ * under the current view.
43
55
  * @csspart field - One field, with `data-name`, and `data-prose` on a value over 60 characters.
44
- * @csspart label - A field's name, and the heading above the view chips.
45
- * @csspart value - A field's value.
56
+ * @csspart label - A field's name, a `<dt>`, and the heading above the view chips.
57
+ * @csspart value - A field's value, a `<dd>`.
58
+ * @csspart more - The Show more button under a long value that is cut short, with `aria-expanded`.
59
+ * @csspart image - A field's value drawn as an image, under `image-fields`.
46
60
  * @csspart scoped - The group-scoped values, grouped by key.
47
61
  * @csspart key - One key's heading among the group-scoped values, with `data-key`.
48
62
  * @csspart open - The Open button.
49
- * @csspart copy - The Copy id button, which copies the `mosaica_id` to the clipboard.
63
+ * @csspart copy - The Copy id button, which copies the `mosaica_id` to the clipboard and says to a
64
+ * screen reader whether it did.
50
65
  */
51
66
  export declare class MosaicaItemCard extends MosaicaElement {
52
67
  static styles: import("lit").CSSResult[];
@@ -75,6 +90,11 @@ export declare class MosaicaItemCard extends MosaicaElement {
75
90
  * Unset, the first three. The full list shows these fields first, then the rest.
76
91
  */
77
92
  accessor cardFields: string;
93
+ /**
94
+ * The fields whose value is the address of an image, separated by spaces or commas. Each is drawn
95
+ * as its image rather than as text.
96
+ */
97
+ accessor imageFields: string;
78
98
  /**
79
99
  * The link template for Open, with `{name}` for the value of the field `name` and `{mosaica_id}`
80
100
  * for the item's id. Without it or `open`, there is no Open button.
@@ -85,6 +105,17 @@ export declare class MosaicaItemCard extends MosaicaElement {
85
105
  /** Whether "Show all" was pressed, for the item it was pressed on. @internal */
86
106
  accessor expanded: boolean;
87
107
  private expandedFor;
108
+ /** The long values shown whole on the full card, by field, for the item shown. @internal */
109
+ accessor opened: ReadonlySet<string>;
110
+ /** The fields whose headline, subtitle or value is cut short where it is drawn. @internal */
111
+ accessor clipped: ReadonlySet<string>;
112
+ /** What the last press of Copy id came to, for the item shown. @internal */
113
+ accessor copied: string;
114
+ private resized;
115
+ /** The image addresses that failed to load, shown as text. @internal */
116
+ accessor broken: ReadonlySet<string>;
117
+ /** `image-fields` as a list, kept in step by `willUpdate`. */
118
+ private imageNames;
88
119
  /** A category value's title as the store holds it, else from the legend or a suggestion page, else its key. */
89
120
  private titleOf;
90
121
  /** A field's value as text: a category value by its title, anything else by its declared type. */
@@ -94,17 +125,30 @@ export declare class MosaicaItemCard extends MosaicaElement {
94
125
  * set before the render, so the render changes nothing it reads.
95
126
  */
96
127
  protected willUpdate(changed: PropertyValues<this>): void;
128
+ connectedCallback(): void;
129
+ disconnectedCallback(): void;
130
+ protected updated(changed: PropertyValues<this>): void;
131
+ /**
132
+ * Note which clamped texts are cut short at the card's width, so each is offered whole. A text
133
+ * shown whole keeps what was noted while it was clamped, so the button that shows it stays.
134
+ */
135
+ private measure;
136
+ /** Copy the id to the clipboard and say in the status region how that went. */
137
+ private copy;
97
138
  private get shown();
98
139
  render(): TemplateResult | typeof nothing;
99
- /** The card under `compact`: headline and subtitle, three fields, and Show all beside Open. */
100
- private compactBody;
140
+ /** An item's headline, for the header row, and what the card shows under it: the full card's, or under `compact` the shorter one's. */
141
+ private card;
101
142
  /**
102
143
  * Open, where the host says what it does: a button that calls `open`, else a link to `open-url`
103
- * filled from the item, else nothing. Each fires `mosaica-open`.
144
+ * filled from the item, which opens in a new tab and says so to a screen reader, else nothing.
145
+ * Each fires `mosaica-open`. `mark` is drawn before the word.
104
146
  */
105
147
  private openButton;
106
148
  /** The fields of `fields` that `card-fields` names, in its order. */
107
149
  private named;
150
+ /** The address of the image a field's value names, where `image-fields` lists the field. */
151
+ private imageOf;
108
152
  /** `fields` with those `card-fields` names first, in its order. */
109
153
  private namedFirst;
110
154
  /**
@@ -124,7 +168,11 @@ export declare class MosaicaItemCard extends MosaicaElement {
124
168
  * key through a `members` group share a heading.
125
169
  */
126
170
  private scoped;
127
- /** One field, presented by its declared type; prose spans the grid. */
171
+ /**
172
+ * One field, presented by its declared type; prose and images span the grid. An image's
173
+ * alternative text is the item's `headline` where it has one, since its caption is the label
174
+ * above it. On the full card, prose a clamp cuts short has a button that shows it whole.
175
+ */
128
176
  private field;
129
177
  }
130
178
  declare global {