@mosaicajs/components 0.1.0-rc.4 → 0.1.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/dist/artifact-card.d.ts +20 -26
  2. package/dist/artifact-card.js +20 -26
  3. package/dist/base.d.ts +21 -29
  4. package/dist/base.js +18 -26
  5. package/dist/basemap.d.ts +2 -2
  6. package/dist/cluster-filter.d.ts +19 -25
  7. package/dist/cluster-filter.js +19 -25
  8. package/dist/colour-editor.d.ts +16 -36
  9. package/dist/colour-editor.js +16 -36
  10. package/dist/context.d.ts +4 -4
  11. package/dist/context.js +4 -4
  12. package/dist/count.d.ts +16 -15
  13. package/dist/count.js +16 -15
  14. package/dist/events.d.ts +63 -68
  15. package/dist/explorer.d.ts +76 -119
  16. package/dist/explorer.js +76 -121
  17. package/dist/field-card.d.ts +24 -56
  18. package/dist/field-card.js +24 -56
  19. package/dist/filter-panel.d.ts +31 -45
  20. package/dist/filter-panel.js +31 -45
  21. package/dist/filter.d.ts +20 -28
  22. package/dist/filter.js +20 -28
  23. package/dist/hierarchy.d.ts +35 -36
  24. package/dist/hierarchy.js +35 -36
  25. package/dist/index.d.ts +5 -4
  26. package/dist/index.js +5 -4
  27. package/dist/item-card.d.ts +34 -55
  28. package/dist/item-card.js +34 -55
  29. package/dist/key-picker.d.ts +5 -5
  30. package/dist/key-picker.js +5 -5
  31. package/dist/layer-picker.d.ts +11 -9
  32. package/dist/layer-picker.js +11 -9
  33. package/dist/map.d.ts +134 -172
  34. package/dist/map.js +136 -188
  35. package/dist/mosaica-components.js +5599 -1594
  36. package/dist/mosaica-components.js.LICENSE.txt +80 -16
  37. package/dist/mosaica-components.js.sri +1 -1
  38. package/dist/mosaica-components.json +2 -2
  39. package/dist/parts.d.ts +3 -4
  40. package/dist/parts.js +3 -4
  41. package/dist/selection.d.ts +21 -27
  42. package/dist/selection.js +21 -27
  43. package/dist/states.d.ts +15 -20
  44. package/dist/status.d.ts +26 -38
  45. package/dist/status.js +26 -38
  46. package/dist/store-element.d.ts +8 -7
  47. package/dist/store-element.js +8 -7
  48. package/dist/tokens.d.ts +12 -13
  49. package/dist/tokens.js +12 -13
  50. package/dist/view-picker.d.ts +10 -6
  51. package/dist/view-picker.js +10 -6
  52. package/package.json +6 -6
@@ -2,64 +2,63 @@ import { nothing, type PropertyValues, type TemplateResult } from 'lit';
2
2
  import { MosaicaElement } from './base.js';
3
3
  import './count.js';
4
4
  /**
5
- * A layer's hierarchy, browsed through `POST /v1/artifacts/browse` independently of the viewport:
6
- * it opens on the roots at any zoom and does not move with the map. A select chooses among the
7
- * bundle's hierarchical layers where there are several. Each row is a name, a masked count and,
8
- * where the server counts children under it, an expander; expanding fetches the children, a page
9
- * at a time under More. On a layer where a child
10
- * may have several parents, a row appears under each parent it is served under and names the
11
- * others. A parent the viewer may not see is absent, so its child reads as a root. The search box
12
- * lists matching names.
5
+ * Use the hierarchy when viewers should be able to reach a layer's artifacts at any level, wherever
6
+ * the camera is. It opens on the top-level artifacts and does not change as the map moves.
7
+ * Expanding a row loads its children a page at a time.
13
8
  *
14
- * The panel sends the map's filters and, while any is set, shows each row's matched count beside
15
- * its masked count. A row's presence and its masked count do not change with the filters. A row's
16
- * buttons put a `member_of` clause on its artifact as a highlight or a filter, and Fit fits the map
17
- * to it on a layer that draws. Pressing the name highlights it. A row holding a clause is filled,
18
- * grey for a filter and in the highlight colour for a highlight, and carries a × per clause that
19
- * takes it off.
9
+ * The hierarchy offers each layer that depends on no other layer and whose artifacts form a
10
+ * hierarchy, filter layers among them. When there are several, a select switches between them.
20
11
  *
21
- * The panel asks for nothing while it is hidden. The element keeps which rows are expanded and
22
- * paged.
12
+ * Each row shows how many of the artifact's items the viewer may see. While filters are set, it
13
+ * also shows how many of those items match. A parent the viewer may not see is left out, so its
14
+ * children appear at the top level.
23
15
  *
24
- * @summary A layer's hierarchy, browsed apart from the viewport.
16
+ * A row's buttons highlight or filter the map by its artifact. Its Fit button only fires
17
+ * `mosaica-artifactfit`, so you handle the event by passing its id to the map's `fitTo`. The
18
+ * explorer does this for a hierarchy you put in one of its slots. `fitTo` finds only the artifacts
19
+ * the map currently draws, so Fit does nothing for a row whose artifact is not drawn at this zoom.
20
+ *
21
+ * The panel makes no requests while it is hidden, so it costs nothing in a closed drawer.
22
+ *
23
+ * @summary A tree for browsing a layer's artifacts and filtering by them.
25
24
  * @tagname mosaica-hierarchy
26
25
  * @category Elements
27
26
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-clausechange']>} mosaica-clausechange - A row's
28
- * name, highlight or filter button put a `member_of` clause on or took it off.
27
+ * name, highlight or filter button added or removed a `member_of` clause.
29
28
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-artifactfit']>} mosaica-artifactfit - A row's Fit
30
29
  * button was pressed.
31
30
  * @csspart title - The heading.
32
31
  * @csspart state - The state line, with `data-state`.
33
- * @csspart refusal - The words "Layer unavailable", with `data-code` set to the refusal's code.
34
- * @csspart reason - The server's reason for a refusal, on a line under "View refused".
35
- * @csspart layer - The layer select, shown where there are several layers.
32
+ * @csspart refusal - The words "View refused" or "Layer unavailable", with `data-code`.
33
+ * @csspart reason - The server's reason for a refusal, under "View refused".
34
+ * @csspart layer - The layer select, shown if there are several layers.
36
35
  * @csspart search - The search box.
37
36
  * @csspart tree - The tree of rows.
38
- * @csspart row - One row, with `data-id`, and `data-clause` while a clause is on its artifact:
39
- * `filter`, `highlight`, or both separated by a space.
40
- * @csspart expander - A row's expand button, with `data-leaf` and hidden where the row has no
41
- * children, so every row's name starts at the same place.
42
- * @csspart name - A row's name, with `data-unnamed` where it has none, which highlights the artifact
43
- * when pressed.
37
+ * @csspart row - One row, with `data-id`, and `data-clause` (`filter`, `highlight` or both,
38
+ * separated by a space) while its artifact is filtered or highlighted.
39
+ * @csspart expander - A row's expand button. On a row with no children it has `data-leaf` and is
40
+ * hidden, keeping the names aligned.
41
+ * @csspart name - A row's name, with `data-unnamed` if it has none. Pressing it highlights the
42
+ * artifact.
44
43
  * @csspart counts - A row's counts.
45
- * @csspart count-matched - A row's matched `<mosaica-count>`, while a filter is set.
46
- * @csspart count-masked - A row's masked `<mosaica-count>`.
44
+ * @csspart count-matched - The `<mosaica-count>` of a row's items that match the filters, while a
45
+ * filter is set.
46
+ * @csspart count-masked - The `<mosaica-count>` of a row's items the viewer may see.
47
47
  * @csspart actions - A row's buttons.
48
48
  * @csspart highlight - A row's highlight button, with `aria-pressed`.
49
49
  * @csspart filter - A row's filter button, with `aria-pressed`.
50
50
  * @csspart fit - A row's Fit button, on a layer that draws.
51
- * @csspart dismiss - A × on a row holding a clause, one per clause, with `data-verb`; it takes that
52
- * clause off.
53
- * @csspart also - The other parents a row is served under, or "Children unavailable" with
54
- * `data-code` where its children were refused.
51
+ * @csspart dismiss - A × that removes a row's filter or highlight, one for each, with `data-verb`.
52
+ * @csspart also - The row's other parents, or "Children unavailable" with `data-code` if its
53
+ * children were refused.
55
54
  * @csspart children - An expanded row's children.
56
- * @csspart more - The More button that fetches the next page.
55
+ * @csspart more - The More button, which loads the next page.
57
56
  */
58
57
  export declare class MosaicaHierarchy extends MosaicaElement {
59
58
  static styles: import("lit").CSSResult[];
60
- /** The layer whose hierarchy is shown. Unset or unknown, the first the bundle offers. */
59
+ /** The layer to browse. Unset or unknown, the first layer the bundle offers. */
61
60
  accessor layer: string;
62
- /** Rows per page, at least 1 and at most the server's `maxBrowseRows`. */
61
+ /** Rows per page, from 1 up to the server's `maxBrowseRows`. */
63
62
  accessor limit: number;
64
63
  private accessor roots;
65
64
  private accessor rootsNext;
package/dist/hierarchy.js CHANGED
@@ -44,58 +44,57 @@ import { chrome, tokens } from './tokens.js';
44
44
  import './count.js';
45
45
  const masked = (n) => ({ value: Number(n), exact: true });
46
46
  /**
47
- * A layer's hierarchy, browsed through `POST /v1/artifacts/browse` independently of the viewport:
48
- * it opens on the roots at any zoom and does not move with the map. A select chooses among the
49
- * bundle's hierarchical layers where there are several. Each row is a name, a masked count and,
50
- * where the server counts children under it, an expander; expanding fetches the children, a page
51
- * at a time under More. On a layer where a child
52
- * may have several parents, a row appears under each parent it is served under and names the
53
- * others. A parent the viewer may not see is absent, so its child reads as a root. The search box
54
- * lists matching names.
47
+ * Use the hierarchy when viewers should be able to reach a layer's artifacts at any level, wherever
48
+ * the camera is. It opens on the top-level artifacts and does not change as the map moves.
49
+ * Expanding a row loads its children a page at a time.
55
50
  *
56
- * The panel sends the map's filters and, while any is set, shows each row's matched count beside
57
- * its masked count. A row's presence and its masked count do not change with the filters. A row's
58
- * buttons put a `member_of` clause on its artifact as a highlight or a filter, and Fit fits the map
59
- * to it on a layer that draws. Pressing the name highlights it. A row holding a clause is filled,
60
- * grey for a filter and in the highlight colour for a highlight, and carries a × per clause that
61
- * takes it off.
51
+ * The hierarchy offers each layer that depends on no other layer and whose artifacts form a
52
+ * hierarchy, filter layers among them. When there are several, a select switches between them.
62
53
  *
63
- * The panel asks for nothing while it is hidden. The element keeps which rows are expanded and
64
- * paged.
54
+ * Each row shows how many of the artifact's items the viewer may see. While filters are set, it
55
+ * also shows how many of those items match. A parent the viewer may not see is left out, so its
56
+ * children appear at the top level.
65
57
  *
66
- * @summary A layer's hierarchy, browsed apart from the viewport.
58
+ * A row's buttons highlight or filter the map by its artifact. Its Fit button only fires
59
+ * `mosaica-artifactfit`, so you handle the event by passing its id to the map's `fitTo`. The
60
+ * explorer does this for a hierarchy you put in one of its slots. `fitTo` finds only the artifacts
61
+ * the map currently draws, so Fit does nothing for a row whose artifact is not drawn at this zoom.
62
+ *
63
+ * The panel makes no requests while it is hidden, so it costs nothing in a closed drawer.
64
+ *
65
+ * @summary A tree for browsing a layer's artifacts and filtering by them.
67
66
  * @tagname mosaica-hierarchy
68
67
  * @category Elements
69
68
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-clausechange']>} mosaica-clausechange - A row's
70
- * name, highlight or filter button put a `member_of` clause on or took it off.
69
+ * name, highlight or filter button added or removed a `member_of` clause.
71
70
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-artifactfit']>} mosaica-artifactfit - A row's Fit
72
71
  * button was pressed.
73
72
  * @csspart title - The heading.
74
73
  * @csspart state - The state line, with `data-state`.
75
- * @csspart refusal - The words "Layer unavailable", with `data-code` set to the refusal's code.
76
- * @csspart reason - The server's reason for a refusal, on a line under "View refused".
77
- * @csspart layer - The layer select, shown where there are several layers.
74
+ * @csspart refusal - The words "View refused" or "Layer unavailable", with `data-code`.
75
+ * @csspart reason - The server's reason for a refusal, under "View refused".
76
+ * @csspart layer - The layer select, shown if there are several layers.
78
77
  * @csspart search - The search box.
79
78
  * @csspart tree - The tree of rows.
80
- * @csspart row - One row, with `data-id`, and `data-clause` while a clause is on its artifact:
81
- * `filter`, `highlight`, or both separated by a space.
82
- * @csspart expander - A row's expand button, with `data-leaf` and hidden where the row has no
83
- * children, so every row's name starts at the same place.
84
- * @csspart name - A row's name, with `data-unnamed` where it has none, which highlights the artifact
85
- * when pressed.
79
+ * @csspart row - One row, with `data-id`, and `data-clause` (`filter`, `highlight` or both,
80
+ * separated by a space) while its artifact is filtered or highlighted.
81
+ * @csspart expander - A row's expand button. On a row with no children it has `data-leaf` and is
82
+ * hidden, keeping the names aligned.
83
+ * @csspart name - A row's name, with `data-unnamed` if it has none. Pressing it highlights the
84
+ * artifact.
86
85
  * @csspart counts - A row's counts.
87
- * @csspart count-matched - A row's matched `<mosaica-count>`, while a filter is set.
88
- * @csspart count-masked - A row's masked `<mosaica-count>`.
86
+ * @csspart count-matched - The `<mosaica-count>` of a row's items that match the filters, while a
87
+ * filter is set.
88
+ * @csspart count-masked - The `<mosaica-count>` of a row's items the viewer may see.
89
89
  * @csspart actions - A row's buttons.
90
90
  * @csspart highlight - A row's highlight button, with `aria-pressed`.
91
91
  * @csspart filter - A row's filter button, with `aria-pressed`.
92
92
  * @csspart fit - A row's Fit button, on a layer that draws.
93
- * @csspart dismiss - A × on a row holding a clause, one per clause, with `data-verb`; it takes that
94
- * clause off.
95
- * @csspart also - The other parents a row is served under, or "Children unavailable" with
96
- * `data-code` where its children were refused.
93
+ * @csspart dismiss - A × that removes a row's filter or highlight, one for each, with `data-verb`.
94
+ * @csspart also - The row's other parents, or "Children unavailable" with `data-code` if its
95
+ * children were refused.
97
96
  * @csspart children - An expanded row's children.
98
- * @csspart more - The More button that fetches the next page.
97
+ * @csspart more - The More button, which loads the next page.
99
98
  */
100
99
  let MosaicaHierarchy = (() => {
101
100
  let _classSuper = MosaicaElement;
@@ -283,11 +282,11 @@ let MosaicaHierarchy = (() => {
283
282
  `
284
283
  ];
285
284
  #layer_accessor_storage = __runInitializers(this, _layer_initializers, '');
286
- /** The layer whose hierarchy is shown. Unset or unknown, the first the bundle offers. */
285
+ /** The layer to browse. Unset or unknown, the first layer the bundle offers. */
287
286
  get layer() { return this.#layer_accessor_storage; }
288
287
  set layer(value) { this.#layer_accessor_storage = value; }
289
288
  #limit_accessor_storage = (__runInitializers(this, _layer_extraInitializers), __runInitializers(this, _limit_initializers, 50));
290
- /** Rows per page, at least 1 and at most the server's `maxBrowseRows`. */
289
+ /** Rows per page, from 1 up to the server's `maxBrowseRows`. */
291
290
  get limit() { return this.#limit_accessor_storage; }
292
291
  set limit(value) { this.#limit_accessor_storage = value; }
293
292
  #roots_accessor_storage = (__runInitializers(this, _limit_extraInitializers), __runInitializers(this, _roots_initializers, null));
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * The `mosaica-*` custom elements. Importing the root entry defines every element. A host that
3
- * wants one element imports its subpath, such as `@mosaicajs/components/count`. The map, the
4
- * explorer, the field card, the filter panel and the colour editor import `@mosaicajs/deck`, which
5
- * depends on deck.gl; the other elements do not.
2
+ * The `mosaica-*` custom elements: the map, the panels that go around it, and `<mosaica-explorer>`,
3
+ * which lays them all out together. Import the package root to define every element, or a subpath
4
+ * such as `@mosaicajs/components/count` to define one. The map, the explorer, the field card, the
5
+ * filter panel and the colour editor import `@mosaicajs/deck`, which depends on deck.gl; the other
6
+ * elements do not.
6
7
  *
7
8
  * @module @mosaicajs/components
8
9
  */
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * The `mosaica-*` custom elements. Importing the root entry defines every element. A host that
3
- * wants one element imports its subpath, such as `@mosaicajs/components/count`. The map, the
4
- * explorer, the field card, the filter panel and the colour editor import `@mosaicajs/deck`, which
5
- * depends on deck.gl; the other elements do not.
2
+ * The `mosaica-*` custom elements: the map, the panels that go around it, and `<mosaica-explorer>`,
3
+ * which lays them all out together. Import the package root to define every element, or a subpath
4
+ * such as `@mosaicajs/components/count` to define one. The map, the explorer, the field card, the
5
+ * filter panel and the colour editor import `@mosaicajs/deck`, which depends on deck.gl; the other
6
+ * elements do not.
6
7
  *
7
8
  * @module @mosaicajs/components
8
9
  */
@@ -3,37 +3,22 @@ import type { ItemDetail, Meta, Refusal } from '@mosaicajs/client';
3
3
  import type { MosaicaEventDetails } from './events.js';
4
4
  import { MosaicaElement, type PickOutcome } from './base.js';
5
5
  /**
6
- * The selected item's record: a headline, the views it is in, its fields as a label and value
7
- * grid, its group-scoped values, then Open and Copy id. Fields are listed by name in
8
- * declaration order, then any the schema does not declare; a field the record has no value for is
9
- * left out. A declared field is captioned in words (`published_at` as "Published at"). A category
10
- * field shows its value's title where the vocabulary has one, else its key; the titles are asked
11
- * of the store (`Store.titleOf`), and an answer is shown only while the store's `meta` is the one
12
- * it was asked under. A timestamp shows in full, as `14 March 2024, 12:00 UTC`.
13
- * The close button appears only while the card shows something: an item, a refusal or a click's
14
- * result.
6
+ * Use the item card to show the record of the item a viewer has picked on the map, so that they can
7
+ * read its fields and open it elsewhere. It reads the store's selected item, or the `item` you set
8
+ * when you fetch records yourself.
15
9
  *
16
- * The headline is the field `title-field` names, else the item's `mosaica_id`. Each field has a
17
- * slot, `field-<name>`, so a host can render one as a link. The item is the store's selection
18
- * (`Store.pick`), or the `item` property.
10
+ * The headline is the `title-field` field, or the item's `mosaica_id` when that field is unset or
11
+ * empty. To render a field your own way, as a link for example, put an element in its
12
+ * `field-<name>` slot.
19
13
  *
20
- * `compact` shows less: the headline, cut at three lines, the field `subtitle-field` names under
21
- * it, cut at two, the fields `card-fields` names (else the first three others), then "Show all N
22
- * fields" beside Open. Show all lists every field, the views and the group-scoped values, and the
23
- * card grows to hold them; a container that sets the card a height, such as the explorer's card
24
- * beside a point, scrolls past it. A host's buttons in the `actions` slot sit beside the close
25
- * button.
14
+ * The Open button appears only when you set `open-url` or `open`. `open-url` is a link template
15
+ * such as `https://www.geonames.org/{geonameid}`, in which each `{name}` is replaced by the item's
16
+ * value for that field. Because the values are URL-encoded, a template cannot open an address that
17
+ * 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`.
26
20
  *
27
- * What Open does is the host's to say, and Open is shown only where it says. The `open` property is
28
- * called with the item's `mosaica_id` and fields. Otherwise `open-url` is a link template, such as
29
- * `https://www.geonames.org/{geonameid}`: each `{name}` is replaced by the item's value for the
30
- * field `name`, URL-encoded, and `{mosaica_id}` by its id where the record has no field of that
31
- * name. Open is then a link to that address, opening in a new tab. An item with no value, or an
32
- * empty one, for a field the template names, or whose address is not `http:` or `https:` once
33
- * filled and resolved against the page, has no Open. Where both are set, `open` is called and
34
- * `open-url` is unused.
35
- *
36
- * @summary The selected item's fields, with Open and Copy id.
21
+ * @summary A card showing an item's fields, with an optional Open button.
37
22
  * @tagname mosaica-item-card
38
23
  * @category Elements
39
24
  * @slot field-<name> - Replaces the value of the field `<name>`, in the grid or the headline.
@@ -42,18 +27,17 @@ import { MosaicaElement, type PickOutcome } from './base.js';
42
27
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-close']>} mosaica-close - The close button was
43
28
  * pressed, with `what` set to `item`.
44
29
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-viewfollow']>} mosaica-viewfollow - A view chip
45
- * was pressed: follow the item into that view, at its position there.
30
+ * was pressed, asking to show the item in that view.
46
31
  * @csspart title - The header row: the headline or the state, and the close button.
47
32
  * @csspart close - The close button.
48
- * @csspart state - The state line, with `data-state`: `shown`, `empty` (no item, or nothing under
49
- * the cursor), `refused` or `detached`.
50
- * @csspart refusal - The words "Item unavailable", with `data-code` set to the refusal's code where
51
- * the server refused the record. A broken pick's details are on the map's `lastPick`.
52
- * @csspart reason - The server's reason for refusing the record, as it sent it, on a line under
53
- * "Item unavailable".
33
+ * @csspart state - The state line, with `data-state`: `shown`, `empty` (no item, or a click that
34
+ * found nothing), `refused` or `detached`.
35
+ * @csspart refusal - The words "Item unavailable", with `data-code` set to the refusal's code if
36
+ * the server refused the record. For a broken pick, the details are in the map's `lastPick`.
37
+ * @csspart reason - The server's reason for refusing the record, under "Item unavailable".
54
38
  * @csspart headline - The headline, with `data-name` set to the field it shows.
55
- * @csspart subtitle - The value of the `subtitle-field` field under the headline, under `compact`.
56
- * @csspart show-all - The "Show all N fields" button, under `compact`, with `aria-expanded`.
39
+ * @csspart subtitle - The `subtitle-field` value under the headline, when `compact` is set.
40
+ * @csspart show-all - The "Show all N fields" button, when `compact` is set, with `aria-expanded`.
57
41
  * @csspart view-chip - One view the item is in, with `data-view` and `aria-current` on the current
58
42
  * view.
59
43
  * @csspart field - One field, with `data-name`, and `data-prose` on a value over 60 characters.
@@ -66,42 +50,37 @@ import { MosaicaElement, type PickOutcome } from './base.js';
66
50
  */
67
51
  export declare class MosaicaItemCard extends MosaicaElement {
68
52
  static styles: import("lit").CSSResult[];
69
- /**
70
- * The item to show, for a host that fetches the record itself. Set with `refusal` or alone, it
71
- * replaces the store's selection.
72
- */
53
+ /** The item to show, if you fetch the record yourself. It replaces the store's selection. */
73
54
  accessor item: {
74
55
  id: bigint;
75
56
  detail: ItemDetail;
76
57
  } | null;
77
- /** A refusal to show in place of an item, for a host that fetches the record itself. */
58
+ /** A refusal to show instead of an item, if you fetch the record yourself. */
78
59
  accessor refusal: Refusal | null;
79
60
  /**
80
- * What the map's last click resolved to (`<mosaica-map>`'s `lastPick`), shown while no item is
81
- * selected: `{kind: 'miss'}` shows "No item here", and a broken pick shows "Item unavailable".
61
+ * What the map's last click found (`<mosaica-map>`'s `lastPick`), shown while no item is
62
+ * selected. A miss shows "No item here" and a broken pick shows "Item unavailable".
82
63
  */
83
64
  accessor pick: PickOutcome;
84
- /** The schema for field order and view names, where the card has no store to read it from. */
65
+ /** The server's `/v1/meta`, for the field order and view names, if the card has no store. */
85
66
  accessor meta: Meta | null;
86
- /** The field the headline shows. Unset, or where the item has no value for it, the headline is the `mosaica_id`. */
67
+ /** The field the headline shows. Unset, or if the item has no value for it, the headline is the `mosaica_id`. */
87
68
  accessor titleField: string;
88
- /** Shows the headline, the subtitle and three fields, with the rest under "Show all N fields". */
69
+ /** Shows a shorter card: the headline, the subtitle and three fields, with the rest under "Show all N fields". */
89
70
  accessor compact: boolean;
90
- /** The field shown under the headline under `compact`. Unset, there is no subtitle. */
71
+ /** The field shown under the headline when `compact` is set. Unset, there is no subtitle. */
91
72
  accessor subtitleField: string;
92
73
  /**
93
- * The fields shown under `compact` before "Show all", space- or comma-separated, in this order.
94
- * Unset, the first three in declaration order. A name the record has no value for, and the
95
- * `title-field` and `subtitle-field` fields, show nothing here. Show all, and the card without
96
- * `compact`, list these fields first and then the rest.
74
+ * The fields a `compact` card shows before "Show all", separated by spaces or commas, in order.
75
+ * Unset, the first three. The full list shows these fields first, then the rest.
97
76
  */
98
77
  accessor cardFields: string;
99
78
  /**
100
- * The address Open goes to, with `{name}` for the value of the field `name` and `{mosaica_id}`
101
- * for the item's id. Unset, and without `open`, there is no Open.
79
+ * The link template for Open, with `{name}` for the value of the field `name` and `{mosaica_id}`
80
+ * for the item's id. Without it or `open`, there is no Open button.
102
81
  */
103
82
  accessor openUrl: string;
104
- /** Called when Open is pressed, with the item's `mosaica_id` and fields. Set, it wins over `open-url`. */
83
+ /** A function called with the item's `mosaica_id` and fields when Open is pressed. Takes precedence over `open-url`. */
105
84
  accessor open: ((item: MosaicaEventDetails['mosaica-open']) => void) | null;
106
85
  /** Whether "Show all" was pressed, for the item it was pressed on. @internal */
107
86
  accessor expanded: boolean;
package/dist/item-card.js CHANGED
@@ -41,37 +41,22 @@ import { icon } from './icons.js';
41
41
  import { reasonOf, refusedState, renderState, stateOf } from './states.js';
42
42
  import { chrome, tokens } from './tokens.js';
43
43
  /**
44
- * The selected item's record: a headline, the views it is in, its fields as a label and value
45
- * grid, its group-scoped values, then Open and Copy id. Fields are listed by name in
46
- * declaration order, then any the schema does not declare; a field the record has no value for is
47
- * left out. A declared field is captioned in words (`published_at` as "Published at"). A category
48
- * field shows its value's title where the vocabulary has one, else its key; the titles are asked
49
- * of the store (`Store.titleOf`), and an answer is shown only while the store's `meta` is the one
50
- * it was asked under. A timestamp shows in full, as `14 March 2024, 12:00 UTC`.
51
- * The close button appears only while the card shows something: an item, a refusal or a click's
52
- * result.
44
+ * Use the item card to show the record of the item a viewer has picked on the map, so that they can
45
+ * read its fields and open it elsewhere. It reads the store's selected item, or the `item` you set
46
+ * when you fetch records yourself.
53
47
  *
54
- * The headline is the field `title-field` names, else the item's `mosaica_id`. Each field has a
55
- * slot, `field-<name>`, so a host can render one as a link. The item is the store's selection
56
- * (`Store.pick`), or the `item` property.
48
+ * The headline is the `title-field` field, or the item's `mosaica_id` when that field is unset or
49
+ * empty. To render a field your own way, as a link for example, put an element in its
50
+ * `field-<name>` slot.
57
51
  *
58
- * `compact` shows less: the headline, cut at three lines, the field `subtitle-field` names under
59
- * it, cut at two, the fields `card-fields` names (else the first three others), then "Show all N
60
- * fields" beside Open. Show all lists every field, the views and the group-scoped values, and the
61
- * card grows to hold them; a container that sets the card a height, such as the explorer's card
62
- * beside a point, scrolls past it. A host's buttons in the `actions` slot sit beside the close
63
- * button.
52
+ * The Open button appears only when you set `open-url` or `open`. `open-url` is a link template
53
+ * such as `https://www.geonames.org/{geonameid}`, in which each `{name}` is replaced by the item's
54
+ * value for that field. Because the values are URL-encoded, a template cannot open an address that
55
+ * a field already holds, so set `open` to a function for that. An item gets no Open button when it
56
+ * has no value for a field the template names. A function in `open` is called with the item's
57
+ * `mosaica_id` and fields, and it takes precedence over `open-url`.
64
58
  *
65
- * What Open does is the host's to say, and Open is shown only where it says. The `open` property is
66
- * called with the item's `mosaica_id` and fields. Otherwise `open-url` is a link template, such as
67
- * `https://www.geonames.org/{geonameid}`: each `{name}` is replaced by the item's value for the
68
- * field `name`, URL-encoded, and `{mosaica_id}` by its id where the record has no field of that
69
- * name. Open is then a link to that address, opening in a new tab. An item with no value, or an
70
- * empty one, for a field the template names, or whose address is not `http:` or `https:` once
71
- * filled and resolved against the page, has no Open. Where both are set, `open` is called and
72
- * `open-url` is unused.
73
- *
74
- * @summary The selected item's fields, with Open and Copy id.
59
+ * @summary A card showing an item's fields, with an optional Open button.
75
60
  * @tagname mosaica-item-card
76
61
  * @category Elements
77
62
  * @slot field-<name> - Replaces the value of the field `<name>`, in the grid or the headline.
@@ -80,18 +65,17 @@ import { chrome, tokens } from './tokens.js';
80
65
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-close']>} mosaica-close - The close button was
81
66
  * pressed, with `what` set to `item`.
82
67
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-viewfollow']>} mosaica-viewfollow - A view chip
83
- * was pressed: follow the item into that view, at its position there.
68
+ * was pressed, asking to show the item in that view.
84
69
  * @csspart title - The header row: the headline or the state, and the close button.
85
70
  * @csspart close - The close button.
86
- * @csspart state - The state line, with `data-state`: `shown`, `empty` (no item, or nothing under
87
- * the cursor), `refused` or `detached`.
88
- * @csspart refusal - The words "Item unavailable", with `data-code` set to the refusal's code where
89
- * the server refused the record. A broken pick's details are on the map's `lastPick`.
90
- * @csspart reason - The server's reason for refusing the record, as it sent it, on a line under
91
- * "Item unavailable".
71
+ * @csspart state - The state line, with `data-state`: `shown`, `empty` (no item, or a click that
72
+ * found nothing), `refused` or `detached`.
73
+ * @csspart refusal - The words "Item unavailable", with `data-code` set to the refusal's code if
74
+ * the server refused the record. For a broken pick, the details are in the map's `lastPick`.
75
+ * @csspart reason - The server's reason for refusing the record, under "Item unavailable".
92
76
  * @csspart headline - The headline, with `data-name` set to the field it shows.
93
- * @csspart subtitle - The value of the `subtitle-field` field under the headline, under `compact`.
94
- * @csspart show-all - The "Show all N fields" button, under `compact`, with `aria-expanded`.
77
+ * @csspart subtitle - The `subtitle-field` value under the headline, when `compact` is set.
78
+ * @csspart show-all - The "Show all N fields" button, when `compact` is set, with `aria-expanded`.
95
79
  * @csspart view-chip - One view the item is in, with `data-view` and `aria-current` on the current
96
80
  * view.
97
81
  * @csspart field - One field, with `data-name`, and `data-prose` on a value over 60 characters.
@@ -296,57 +280,52 @@ let MosaicaItemCard = (() => {
296
280
  `
297
281
  ];
298
282
  #item_accessor_storage = __runInitializers(this, _item_initializers, null);
299
- /**
300
- * The item to show, for a host that fetches the record itself. Set with `refusal` or alone, it
301
- * replaces the store's selection.
302
- */
283
+ /** The item to show, if you fetch the record yourself. It replaces the store's selection. */
303
284
  get item() { return this.#item_accessor_storage; }
304
285
  set item(value) { this.#item_accessor_storage = value; }
305
286
  #refusal_accessor_storage = (__runInitializers(this, _item_extraInitializers), __runInitializers(this, _refusal_initializers, null));
306
- /** A refusal to show in place of an item, for a host that fetches the record itself. */
287
+ /** A refusal to show instead of an item, if you fetch the record yourself. */
307
288
  get refusal() { return this.#refusal_accessor_storage; }
308
289
  set refusal(value) { this.#refusal_accessor_storage = value; }
309
290
  #pick_accessor_storage = (__runInitializers(this, _refusal_extraInitializers), __runInitializers(this, _pick_initializers, null));
310
291
  /**
311
- * What the map's last click resolved to (`<mosaica-map>`'s `lastPick`), shown while no item is
312
- * selected: `{kind: 'miss'}` shows "No item here", and a broken pick shows "Item unavailable".
292
+ * What the map's last click found (`<mosaica-map>`'s `lastPick`), shown while no item is
293
+ * selected. A miss shows "No item here" and a broken pick shows "Item unavailable".
313
294
  */
314
295
  get pick() { return this.#pick_accessor_storage; }
315
296
  set pick(value) { this.#pick_accessor_storage = value; }
316
297
  #meta_accessor_storage = (__runInitializers(this, _pick_extraInitializers), __runInitializers(this, _meta_initializers, null));
317
- /** The schema for field order and view names, where the card has no store to read it from. */
298
+ /** The server's `/v1/meta`, for the field order and view names, if the card has no store. */
318
299
  get meta() { return this.#meta_accessor_storage; }
319
300
  set meta(value) { this.#meta_accessor_storage = value; }
320
301
  #titleField_accessor_storage = (__runInitializers(this, _meta_extraInitializers), __runInitializers(this, _titleField_initializers, ''));
321
- /** The field the headline shows. Unset, or where the item has no value for it, the headline is the `mosaica_id`. */
302
+ /** The field the headline shows. Unset, or if the item has no value for it, the headline is the `mosaica_id`. */
322
303
  get titleField() { return this.#titleField_accessor_storage; }
323
304
  set titleField(value) { this.#titleField_accessor_storage = value; }
324
305
  #compact_accessor_storage = (__runInitializers(this, _titleField_extraInitializers), __runInitializers(this, _compact_initializers, false));
325
- /** Shows the headline, the subtitle and three fields, with the rest under "Show all N fields". */
306
+ /** Shows a shorter card: the headline, the subtitle and three fields, with the rest under "Show all N fields". */
326
307
  get compact() { return this.#compact_accessor_storage; }
327
308
  set compact(value) { this.#compact_accessor_storage = value; }
328
309
  #subtitleField_accessor_storage = (__runInitializers(this, _compact_extraInitializers), __runInitializers(this, _subtitleField_initializers, ''));
329
- /** The field shown under the headline under `compact`. Unset, there is no subtitle. */
310
+ /** The field shown under the headline when `compact` is set. Unset, there is no subtitle. */
330
311
  get subtitleField() { return this.#subtitleField_accessor_storage; }
331
312
  set subtitleField(value) { this.#subtitleField_accessor_storage = value; }
332
313
  #cardFields_accessor_storage = (__runInitializers(this, _subtitleField_extraInitializers), __runInitializers(this, _cardFields_initializers, ''));
333
314
  /**
334
- * The fields shown under `compact` before "Show all", space- or comma-separated, in this order.
335
- * Unset, the first three in declaration order. A name the record has no value for, and the
336
- * `title-field` and `subtitle-field` fields, show nothing here. Show all, and the card without
337
- * `compact`, list these fields first and then the rest.
315
+ * The fields a `compact` card shows before "Show all", separated by spaces or commas, in order.
316
+ * Unset, the first three. The full list shows these fields first, then the rest.
338
317
  */
339
318
  get cardFields() { return this.#cardFields_accessor_storage; }
340
319
  set cardFields(value) { this.#cardFields_accessor_storage = value; }
341
320
  #openUrl_accessor_storage = (__runInitializers(this, _cardFields_extraInitializers), __runInitializers(this, _openUrl_initializers, ''));
342
321
  /**
343
- * The address Open goes to, with `{name}` for the value of the field `name` and `{mosaica_id}`
344
- * for the item's id. Unset, and without `open`, there is no Open.
322
+ * The link template for Open, with `{name}` for the value of the field `name` and `{mosaica_id}`
323
+ * for the item's id. Without it or `open`, there is no Open button.
345
324
  */
346
325
  get openUrl() { return this.#openUrl_accessor_storage; }
347
326
  set openUrl(value) { this.#openUrl_accessor_storage = value; }
348
327
  #open_accessor_storage = (__runInitializers(this, _openUrl_extraInitializers), __runInitializers(this, _open_initializers, null));
349
- /** Called when Open is pressed, with the item's `mosaica_id` and fields. Set, it wins over `open-url`. */
328
+ /** A function called with the item's `mosaica_id` and fields when Open is pressed. Takes precedence over `open-url`. */
350
329
  get open() { return this.#open_accessor_storage; }
351
330
  set open(value) { this.#open_accessor_storage = value; }
352
331
  #expanded_accessor_storage = (__runInitializers(this, _open_extraInitializers), __runInitializers(this, _expanded_initializers, false));
@@ -1,17 +1,17 @@
1
1
  import { nothing, type PropertyValues, type TemplateResult } from 'lit';
2
2
  import { MosaicaElement } from './base.js';
3
3
  /**
4
- * Which view of the current view's group: a select over the group's views in creation order, with
5
- * previous and next buttons that stop at the ends. Each entry shows the view's label and its key.
6
- * Renders nothing when the current view is in no group.
4
+ * Use the key picker when the views of a group follow one another, such as one view per year, so
5
+ * that viewers can step through them in order. The menu lists the group's views in the order they
6
+ * were created. The picker shows nothing while the current view is in no group.
7
7
  *
8
- * @summary Chooses the view within the current group.
8
+ * @summary A drop-down with previous and next buttons for stepping through a group of views.
9
9
  * @tagname mosaica-key-picker
10
10
  * @category Elements
11
11
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-viewswitch']>} mosaica-viewswitch - The view
12
12
  * changed.
13
13
  * @csspart field - The caption and the row.
14
- * @csspart label - The caption, which is the group's name.
14
+ * @csspart label - The caption, the group's name.
15
15
  * @csspart entry - The row of buttons and select.
16
16
  * @csspart select - The select.
17
17
  * @csspart step - A previous or next button, with `data-direction` set to `prev` or `next`.
@@ -6,17 +6,17 @@ import { icon } from './icons.js';
6
6
  import { switchView } from './view-switch.js';
7
7
  import { chrome, tokens } from './tokens.js';
8
8
  /**
9
- * Which view of the current view's group: a select over the group's views in creation order, with
10
- * previous and next buttons that stop at the ends. Each entry shows the view's label and its key.
11
- * Renders nothing when the current view is in no group.
9
+ * Use the key picker when the views of a group follow one another, such as one view per year, so
10
+ * that viewers can step through them in order. The menu lists the group's views in the order they
11
+ * were created. The picker shows nothing while the current view is in no group.
12
12
  *
13
- * @summary Chooses the view within the current group.
13
+ * @summary A drop-down with previous and next buttons for stepping through a group of views.
14
14
  * @tagname mosaica-key-picker
15
15
  * @category Elements
16
16
  * @fires {CustomEvent<MosaicaEventDetails['mosaica-viewswitch']>} mosaica-viewswitch - The view
17
17
  * changed.
18
18
  * @csspart field - The caption and the row.
19
- * @csspart label - The caption, which is the group's name.
19
+ * @csspart label - The caption, the group's name.
20
20
  * @csspart entry - The row of buttons and select.
21
21
  * @csspart select - The select.
22
22
  * @csspart step - A previous or next button, with `data-direction` set to `prev` or `next`.