@c2n/list-item 0.0.18 → 0.0.19

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.
@@ -1 +1 @@
1
- {"schemaVersion":"1.0.0","readme":"","modules":[{"kind":"javascript-module","path":"src/list-item.ts","declarations":[{"kind":"class","description":"A selectable row. On its own it is a toggle: click, Enter or Space flips `selected`. Inside a `c2-list` (and\ntherefore inside a `c2-select`) the list drives the selected state through context, handles the keyboard and the row\nonly reports clicks. The default slot is the primary text, `description` a second, muted line, `prefix-icon` and\n`suffix-icon` take an inline SVG, a `c2-feather-*` icon or a `c2-mat-icon` and are sized by\n`--c2-list-item__icon--size` — anything else in them, a shortcut hint or a badge, keeps its own size.\nWith `href` the row is a link. In a multiple-selection list, adjacent selected rows lose the corner radius between\nthem (the list marks them `joined-before` / `joined-after`) so a run of selected rows reads as one block.\n\nAccessibility: standalone rows are `role=\"button\"` with `aria-pressed`; rows in a list are `role=\"option\"` with\n`aria-selected` and a roving `tabindex` managed by the list. Set your own `role` to override.","name":"ListItem","cssProperties":[{"type":{"text":"pixel"},"name":"--c2-list-item--min-height","default":"36px"},{"type":{"text":"pixel"},"description":"Space between the icons and the content.","name":"--c2-list-item--gap","default":"8px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-top-left-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-top-right-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-bottom-left-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-bottom-right-radius","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-top","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-right","default":"10px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-bottom","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-left","default":"10px"},{"type":{"text":"font-size"},"name":"--c2-list-item--font-size","default":"14px"},{"type":{"text":"font-weight"},"name":"--c2-list-item--font-weight"},{"type":{"text":"font-style"},"name":"--c2-list-item--font-style"},{"type":{"text":"font-family"},"name":"--c2-list-item--font-family"},{"type":{"text":"pixel"},"name":"--c2-list-item--line-height","default":"20px"},{"type":{"text":"border"},"name":"--c2-list-item--border-top"},{"type":{"text":"border"},"name":"--c2-list-item--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item--border-right"},{"type":{"text":"border"},"name":"--c2-list-item--border-left"},{"type":{"text":"color"},"name":"--c2-list-item--color","default":"#18181b"},{"type":{"text":"color"},"name":"--c2-list-item--background","default":"transparent"},{"type":{"text":"color"},"name":"--c2-list-item__description--color","default":"#71717a"},{"type":{"text":"font-size"},"name":"--c2-list-item__description--font-size","default":"12px"},{"type":{"text":"pixel"},"name":"--c2-list-item__description--line-height","default":"16px"},{"type":{"text":"pixel"},"name":"--c2-list-item__description--margin-top","default":"1px"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-top"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-right"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-left"},{"type":{"text":"color"},"name":"--c2-list-item__hover--color"},{"type":{"text":"color"},"name":"--c2-list-item__hover--background","default":"#f4f4f5"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-top"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-right"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-left"},{"type":{"text":"color"},"name":"--c2-list-item__selected--color","default":"#2f56e6"},{"type":{"text":"color"},"name":"--c2-list-item__selected--background","default":"#edf1fe"},{"type":{"text":"color"},"name":"--c2-list-item__selected__hover--background","default":"#e2e9fd"},{"type":{"text":"color"},"description":"Defaults to the description colour.","name":"--c2-list-item__selected__description--color"},{"type":{"text":"outline"},"name":"--c2-list-item__focus--outline","default":"2px solid rgba(2, 101, 220, 0.4)"},{"type":{"text":"pixel"},"name":"--c2-list-item__focus--outline-offset","default":"-2px"},{"type":{"text":"opacity"},"name":"--c2-list-item__disabled--opacity","default":"0.38"},{"type":{"text":"pixel"},"name":"--c2-list-item__icon--size","default":"16px"},{"type":{"text":"color"},"description":"Defaults to the row text colour.","name":"--c2-list-item__icon--color"}],"slots":[{"description":"The row content. Falls back to `label`, then `value`, when empty.","name":"default"},{"description":"Secondary line under the content (muted, smaller).","name":"description"},{"description":"Icon (or avatar, badge, …) shown before the content.","name":"prefix-icon"},{"description":"Icon shown after the content, e.g. a check mark or shortcut hint.","name":"suffix-icon"}],"members":[{"kind":"field","name":"contextConsumer","privacy":"private","default":"new ContextConsumer(this, { context: selectedItemValueContext, subscribe: true, callback: (value) => { this.selected = value ? value.includes(this.value) : false }, })"},{"kind":"field","name":"selected","type":{"text":"boolean"},"default":"false","description":"Whether the row is selected. Toggled by a click on a standalone row; controlled by the list otherwise.","attribute":"selected","reflects":true},{"kind":"field","name":"disabled","type":{"text":"boolean"},"default":"false","description":"Dims the row and ignores clicks and keyboard.","attribute":"disabled","reflects":true},{"kind":"field","name":"value","type":{"text":"string"},"default":"''","description":"The value reported to the parent list / select.","attribute":"value","reflects":true},{"kind":"field","name":"label","type":{"text":"string | undefined"},"description":"Text shown by the parent select for this row instead of the slotted content. Also the fallback content of the\ndefault slot when it is empty. Use it when the row content is rich (icons, two lines) but the trigger should show a\nshort label.","attribute":"label","reflects":true},{"kind":"field","name":"href","type":{"text":"string | undefined"},"default":"undefined","description":"Makes the row a link. Selection still works when the row sits in a list.","attribute":"href"},{"kind":"field","name":"target","type":{"text":"string | undefined"},"default":"undefined","description":"Browsing context used when `href` is set, such as `_blank`.","attribute":"target"},{"kind":"field","name":"data","type":{"text":"unknown | undefined"},"description":"Arbitrary payload returned alongside `value` in the list's `selection-change` event. Not an attribute."},{"kind":"field","name":"applyContext","type":{"text":"boolean"},"default":"false","description":"Private property, it will use context value to setup selected state of component."},{"kind":"field","name":"slotPresence","privacy":"private","readonly":true,"default":"new SlotPresenceController(this, ['description'])"},{"kind":"field","name":"contentSlot","type":{"text":"HTMLSlotElement"},"privacy":"private"},{"kind":"field","name":"authorRole","type":{"text":"string | null"},"privacy":"private","default":"null","description":"`role` written by the author, kept over the automatic one."},{"kind":"field","name":"displayText","type":{"text":"string"},"description":"The text a `c2-select` shows for this row: `label` when set, otherwise the text content of the default slot.","readonly":true},{"kind":"field","name":"blockDisabledClick","privacy":"private"},{"kind":"method","name":"activate","description":"Behaves like a click: dispatches `click` on the row and, for a standalone row, toggles `selected`."},{"kind":"field","name":"handleClick","privacy":"private"},{"kind":"field","name":"handleKeydown","privacy":"private"},{"kind":"method","name":"syncAria","privacy":"private"},{"kind":"method","name":"renderInner","privacy":"private"}],"events":[{"name":"click","type":{"text":"MouseEvent"},"description":"Fired when an enabled row is activated; a row with `href` also navigates."},{"name":"selected-change","type":{"text":"CustomEvent<{ selected: boolean; value: string }>"},"description":"Fired after `selected` changes, whether from a click or from the parent list."}],"attributes":[{"name":"selected","type":{"text":"boolean"},"default":"false","description":"Whether the row is selected. Toggled by a click on a standalone row; controlled by the list otherwise.","fieldName":"selected"},{"name":"disabled","type":{"text":"boolean"},"default":"false","description":"Dims the row and ignores clicks and keyboard.","fieldName":"disabled"},{"name":"value","type":{"text":"string"},"default":"''","description":"The value reported to the parent list / select.","fieldName":"value"},{"name":"label","type":{"text":"string | undefined"},"description":"Text shown by the parent select for this row instead of the slotted content. Also the fallback content of the\ndefault slot when it is empty. Use it when the row content is rich (icons, two lines) but the trigger should show a\nshort label.","fieldName":"label"},{"name":"href","type":{"text":"string | undefined"},"default":"undefined","description":"Makes the row a link. Selection still works when the row sits in a list.","fieldName":"href"},{"name":"target","type":{"text":"string | undefined"},"default":"undefined","description":"Browsing context used when `href` is set, such as `_blank`.","fieldName":"target"}],"superclass":{"name":"LitElement","package":"lit"},"tagName":"c2-list-item","customElement":true}],"exports":[{"kind":"js","name":"ListItem","declaration":{"name":"ListItem","module":"src/list-item.ts"}},{"kind":"custom-element-definition","name":"c2-list-item","declaration":{"name":"ListItem","module":"src/list-item.ts"}}]}]}
1
+ {"schemaVersion":"1.0.0","readme":"","modules":[{"kind":"javascript-module","path":"src/list-item.ts","declarations":[{"kind":"class","description":"A selectable row. On its own it is a toggle: click, Enter or Space flips `selected`. Inside a `c2-list` (and\ntherefore inside a `c2-select`) the list drives the selected state through context, handles the keyboard and the row\nonly reports clicks. The default slot is the primary text, `description` a second, muted line, `prefix-icon` and\n`suffix-icon` take an inline SVG, a `c2-feather-*` icon or a `c2-mat-icon` and are sized by\n`--c2-list-item__icon--size` — anything else in them, a shortcut hint or a badge, keeps its own size.\nWith `href` the row is a link. In a multiple-selection list, adjacent selected rows lose the corner radius between\nthem (the list marks them `joined-before` / `joined-after`) so a run of selected rows reads as one block.\n\nAccessibility: standalone rows are `role=\"button\"` with `aria-pressed`; rows in a list are `role=\"option\"` with\n`aria-selected` and a roving `tabindex` managed by the list. Set your own `role` to override.","name":"ListItem","cssProperties":[{"type":{"text":"pixel"},"name":"--c2-list-item--min-height","default":"36px"},{"type":{"text":"pixel"},"description":"Space between the icons and the content.","name":"--c2-list-item--gap","default":"8px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-top-left-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-top-right-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-bottom-left-radius","default":"6px"},{"type":{"text":"border-radius"},"name":"--c2-list-item--border-bottom-right-radius","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-top","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-right","default":"10px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-bottom","default":"6px"},{"type":{"text":"padding"},"name":"--c2-list-item--padding-left","default":"10px"},{"type":{"text":"font-size"},"name":"--c2-list-item--font-size","default":"14px"},{"type":{"text":"font-weight"},"name":"--c2-list-item--font-weight"},{"type":{"text":"font-style"},"name":"--c2-list-item--font-style"},{"type":{"text":"font-family"},"name":"--c2-list-item--font-family"},{"type":{"text":"pixel"},"name":"--c2-list-item--line-height","default":"20px"},{"type":{"text":"border"},"name":"--c2-list-item--border-top"},{"type":{"text":"border"},"name":"--c2-list-item--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item--border-right"},{"type":{"text":"border"},"name":"--c2-list-item--border-left"},{"type":{"text":"color"},"name":"--c2-list-item--color","default":"#18181b"},{"type":{"text":"color"},"name":"--c2-list-item--background","default":"transparent"},{"type":{"text":"color"},"name":"--c2-list-item__description--color","default":"#71717a"},{"type":{"text":"font-size"},"name":"--c2-list-item__description--font-size","default":"12px"},{"type":{"text":"pixel"},"name":"--c2-list-item__description--line-height","default":"16px"},{"type":{"text":"pixel"},"name":"--c2-list-item__description--margin-top","default":"1px"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-top"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-right"},{"type":{"text":"border"},"name":"--c2-list-item__hover--border-left"},{"type":{"text":"color"},"name":"--c2-list-item__hover--color"},{"type":{"text":"color"},"name":"--c2-list-item__hover--background","default":"#f4f4f5"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-top"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-bottom"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-right"},{"type":{"text":"border"},"name":"--c2-list-item__selected--border-left"},{"type":{"text":"color"},"name":"--c2-list-item__selected--color","default":"#2f56e6"},{"type":{"text":"color"},"name":"--c2-list-item__selected--background","default":"#edf1fe"},{"type":{"text":"color"},"name":"--c2-list-item__selected__hover--background","default":"#e2e9fd"},{"type":{"text":"color"},"description":"Defaults to the description colour.","name":"--c2-list-item__selected__description--color"},{"type":{"text":"outline"},"name":"--c2-list-item__focus--outline","default":"2px solid rgba(2, 101, 220, 0.4)"},{"type":{"text":"pixel"},"name":"--c2-list-item__focus--outline-offset","default":"-2px"},{"type":{"text":"opacity"},"name":"--c2-list-item__disabled--opacity","default":"0.38"},{"type":{"text":"pixel"},"name":"--c2-list-item__icon--size","default":"16px"},{"type":{"text":"color"},"description":"Defaults to the row text colour.","name":"--c2-list-item__icon--color"}],"slots":[{"description":"The row content. Falls back to `label`, then `value`, when empty.","name":"default"},{"description":"Secondary line under the content (muted, smaller).","name":"description"},{"description":"Icon (or avatar, badge, …) shown before the content.","name":"prefix-icon"},{"description":"Icon shown after the content, e.g. a check mark or shortcut hint.","name":"suffix-icon"}],"members":[{"kind":"field","name":"contextConsumer","privacy":"private","default":"new ContextConsumer(this, { context: selectedItemValueContext, subscribe: true, callback: (value) => { this.selected = value ? value.includes(this.value) : false }, })"},{"kind":"field","name":"selected","type":{"text":"boolean"},"default":"false","description":"Whether the row is selected. Toggled by a click on a standalone row; controlled by the list otherwise.","attribute":"selected","reflects":true},{"kind":"field","name":"disabled","type":{"text":"boolean"},"default":"false","description":"Dims the row and ignores clicks and keyboard.","attribute":"disabled","reflects":true},{"kind":"field","name":"value","type":{"text":"string"},"default":"''","description":"The value reported to the parent list / select.","attribute":"value","reflects":true},{"kind":"field","name":"label","type":{"text":"string | undefined"},"description":"Text shown by the parent select for this row instead of the slotted content. Also the fallback content of the\ndefault slot when it is empty. Use it when the row content is rich (icons, two lines) but the trigger should show a\nshort label.","attribute":"label","reflects":true},{"kind":"field","name":"href","type":{"text":"string | undefined"},"default":"undefined","description":"Makes the row a link. Selection still works when the row sits in a list.","attribute":"href"},{"kind":"field","name":"target","type":{"text":"string | undefined"},"default":"undefined","description":"Browsing context used when `href` is set, such as `_blank`.","attribute":"target"},{"kind":"field","name":"data","type":{"text":"unknown | undefined"},"description":"Arbitrary payload returned alongside `value` in the list's `selection-change` event. Not an attribute."},{"kind":"field","name":"applyContext","type":{"text":"boolean"},"default":"false","description":"Private property, it will use context value to setup selected state of component."},{"kind":"field","name":"slotPresence","privacy":"private","readonly":true,"default":"new SlotPresenceController(this, ['description'])"},{"kind":"field","name":"contentSlot","type":{"text":"HTMLSlotElement"},"privacy":"private"},{"kind":"field","name":"internals","privacy":"private","readonly":true},{"kind":"field","name":"displayText","type":{"text":"string"},"description":"The text a `c2-select` shows for this row: `label` when set, otherwise the text content of the default slot.","readonly":true},{"kind":"field","name":"blockDisabledClick","privacy":"private"},{"kind":"method","name":"activate","description":"Behaves like a click: dispatches `click` on the row and, for a standalone row, toggles `selected`."},{"kind":"field","name":"handleClick","privacy":"private"},{"kind":"field","name":"handleKeydown","privacy":"private"},{"kind":"method","name":"syncAria","privacy":"private"},{"kind":"method","name":"renderInner","privacy":"private"}],"events":[{"name":"click","type":{"text":"MouseEvent"},"description":"Fired when an enabled row is activated; a row with `href` also navigates."},{"name":"selected-change","type":{"text":"CustomEvent<{ selected: boolean; value: string }>"},"description":"Fired after `selected` changes, whether from a click or from the parent list."}],"attributes":[{"name":"selected","type":{"text":"boolean"},"default":"false","description":"Whether the row is selected. Toggled by a click on a standalone row; controlled by the list otherwise.","fieldName":"selected"},{"name":"disabled","type":{"text":"boolean"},"default":"false","description":"Dims the row and ignores clicks and keyboard.","fieldName":"disabled"},{"name":"value","type":{"text":"string"},"default":"''","description":"The value reported to the parent list / select.","fieldName":"value"},{"name":"label","type":{"text":"string | undefined"},"description":"Text shown by the parent select for this row instead of the slotted content. Also the fallback content of the\ndefault slot when it is empty. Use it when the row content is rich (icons, two lines) but the trigger should show a\nshort label.","fieldName":"label"},{"name":"href","type":{"text":"string | undefined"},"default":"undefined","description":"Makes the row a link. Selection still works when the row sits in a list.","fieldName":"href"},{"name":"target","type":{"text":"string | undefined"},"default":"undefined","description":"Browsing context used when `href` is set, such as `_blank`.","fieldName":"target"}],"superclass":{"name":"LitElement","package":"lit"},"tagName":"c2-list-item","customElement":true}],"exports":[{"kind":"js","name":"ListItem","declaration":{"name":"ListItem","module":"src/list-item.ts"}},{"kind":"custom-element-definition","name":"c2-list-item","declaration":{"name":"ListItem","module":"src/list-item.ts"}}]}]}
package/dist/list-item.js CHANGED
@@ -35,7 +35,7 @@ var ListItem = class ListItem extends LitElement {
35
35
  this.target = void 0;
36
36
  this.applyContext = false;
37
37
  this.slotPresence = new SlotPresenceController(this, ["description"]);
38
- this.authorRole = null;
38
+ this.internals = this.attachInternals();
39
39
  this.blockDisabledClick = (event) => {
40
40
  if (!this.disabled) return;
41
41
  event.preventDefault();
@@ -68,7 +68,6 @@ var ListItem = class ListItem extends LitElement {
68
68
  }
69
69
  connectedCallback() {
70
70
  super.connectedCallback();
71
- if (this.authorRole === null) this.authorRole = this.getAttribute("role");
72
71
  this.addEventListener("keydown", this.handleKeydown);
73
72
  this.addEventListener("click", this.blockDisabledClick, true);
74
73
  }
@@ -105,20 +104,11 @@ var ListItem = class ListItem extends LitElement {
105
104
  }
106
105
  syncAria() {
107
106
  const inList = this.applyContext;
108
- const role = this.authorRole ?? (this.href ? "link" : inList ? "option" : "button");
109
- this.setAttribute("role", role);
110
- if (role === "option") {
111
- this.setAttribute("aria-selected", String(this.selected));
112
- this.removeAttribute("aria-pressed");
113
- } else if (role === "button") {
114
- this.setAttribute("aria-pressed", String(this.selected));
115
- this.removeAttribute("aria-selected");
116
- } else {
117
- this.removeAttribute("aria-selected");
118
- this.removeAttribute("aria-pressed");
119
- }
120
- if (this.disabled) this.setAttribute("aria-disabled", "true");
121
- else this.removeAttribute("aria-disabled");
107
+ const role = this.getAttribute("role") ?? (this.href ? "link" : inList ? "option" : "button");
108
+ this.internals.role = role;
109
+ this.internals.ariaSelected = role === "option" ? String(this.selected) : null;
110
+ this.internals.ariaPressed = role === "button" ? String(this.selected) : null;
111
+ this.internals.ariaDisabled = this.disabled ? "true" : null;
122
112
  if (!inList) this.tabIndex = this.disabled ? -1 : 0;
123
113
  else if (this.disabled) this.tabIndex = -1;
124
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c2n/list-item",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "main": "dist/list-item.js",
6
6
  "exports": {
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "dependencies": {
68
- "@c2n/core": "0.0.18",
68
+ "@c2n/core": "0.0.19",
69
69
  "@lit/context": "1.1.6",
70
70
  "lit": "3.3.3"
71
71
  },
@@ -73,5 +73,5 @@
73
73
  "@c2n/config": "*"
74
74
  },
75
75
  "customElements": "custom-elements.json",
76
- "gitHead": "fda447c5290caf4e16fdb810d8f89b91ecb3b7db"
76
+ "gitHead": "97db30ae10cfe0b1571ba5081116bc134422fce4"
77
77
  }
@@ -117,8 +117,7 @@ export declare class ListItem extends LitElement {
117
117
  applyContext: boolean;
118
118
  private readonly slotPresence;
119
119
  private contentSlot;
120
- /** `role` written by the author, kept over the automatic one. */
121
- private authorRole;
120
+ private readonly internals;
122
121
  /** The text a `c2-select` shows for this row: `label` when set, otherwise the text content of the default slot. */
123
122
  get displayText(): string;
124
123
  connectedCallback(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/list-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAIjF,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAOhG,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,WAAW,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACpE,KAAK,EAAE,UAAU,CAAA;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IACnE,mBAAmB,EAAE,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;CAC1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,kBAAkB,CAIzB;IAED,yGAAyG;IACzG,QAAQ;IAMR,OAAO,CAAC,WAAW,CAWlB;IAED,OAAO,CAAC,aAAa,CAQpB;cAEkB,UAAU,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;cAU3D,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;IAc3E,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,WAAW;IAaV,MAAM;CAchB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,QAAQ,CAAA;KACzB;CACF"}
package/vue.d.ts CHANGED
@@ -8,17 +8,20 @@
8
8
  // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
9
 
10
10
  import type { DefineComponent, HTMLAttributes } from 'vue'
11
- import type { ListItem, ListItemEventMap } from '@c2n/list-item'
11
+ import type { EventMapOf } from '@c2n/core/event-helper.js'
12
+ import type { ListItem } from '@c2n/list-item'
12
13
 
13
14
  /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
15
  type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
16
+ /** The event an element fires under `name`, read from the map its `addEventListener` carries (its own or inherited). */
17
+ type EventOf<T extends EventTarget, Name extends string> = Name extends keyof EventMapOf<T> ? EventMapOf<T>[Name] : CustomEvent
15
18
 
16
19
  declare module 'vue' {
17
20
  interface GlobalComponents {
18
21
  'c2-list-item': DefineComponent<
19
22
  C2Props<ListItem> & {
20
- onClick?: (event: ListItemEventMap['click']) => void
21
- onSelectedChange?: (event: ListItemEventMap['selected-change']) => void
23
+ onClick?: (event: EventOf<ListItem, 'click'>) => void
24
+ onSelectedChange?: (event: EventOf<ListItem, 'selected-change'>) => void
22
25
  }
23
26
  >
24
27
  }