@c2n/list 0.0.6 → 0.0.8
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.
- package/dist/list.js +8 -6
- package/package.json +19 -7
- package/react.d.ts +24 -0
- package/react.js +3 -0
- package/types/src/list.d.ts +10 -1
- package/types/src/list.d.ts.map +1 -1
- package/vue.d.ts +33 -0
- package/vue.js +3 -0
package/dist/list.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, unsafeCSS } from "lit";
|
|
2
|
-
import {
|
|
2
|
+
import { property, query } from "lit/decorators.js";
|
|
3
|
+
import { customElement } from "@c2n/core/element-helper.js";
|
|
3
4
|
import { selectedItemValueContext } from "@c2n/list-item/list-item-context.js";
|
|
4
5
|
import { ListItem } from "@c2n/list-item";
|
|
5
6
|
import { arrayPropertyConverter } from "@c2n/core/lit-helper.js";
|
|
@@ -206,6 +207,7 @@ var List = class List extends LitElement {
|
|
|
206
207
|
if (focus) item.focus();
|
|
207
208
|
}
|
|
208
209
|
handleListItemClick(event) {
|
|
210
|
+
if (this.disabled) return;
|
|
209
211
|
const target = event.target;
|
|
210
212
|
if (target instanceof ListItem && !target.disabled) {
|
|
211
213
|
this.setFocusedItem(target, false);
|
|
@@ -266,7 +268,7 @@ var List = class List extends LitElement {
|
|
|
266
268
|
}
|
|
267
269
|
dispatchSelectionChangeEvent() {
|
|
268
270
|
this.dispatchEvent(new CustomEvent("selection-change", {
|
|
269
|
-
bubbles:
|
|
271
|
+
bubbles: false,
|
|
270
272
|
cancelable: true,
|
|
271
273
|
detail: {
|
|
272
274
|
value: this.value,
|
|
@@ -276,15 +278,15 @@ var List = class List extends LitElement {
|
|
|
276
278
|
}
|
|
277
279
|
/** Flush lists (no vertical padding) let the first and last rows take the list's corner radius. */
|
|
278
280
|
syncPaddingClasses() {
|
|
279
|
-
const
|
|
280
|
-
this.classList.toggle("padding-top-0",
|
|
281
|
-
this.classList.toggle("padding-bottom-0",
|
|
281
|
+
const style = getComputedStyle(this);
|
|
282
|
+
this.classList.toggle("padding-top-0", style.paddingTop === "0px");
|
|
283
|
+
this.classList.toggle("padding-bottom-0", style.paddingBottom === "0px");
|
|
282
284
|
}
|
|
283
285
|
willUpdate(changedProperties) {
|
|
284
286
|
if (changedProperties.has("value") && typeof this.value === "string") this.value = arrayPropertyConverter.fromAttribute(this.value);
|
|
285
287
|
}
|
|
286
288
|
updated(changedProperties) {
|
|
287
|
-
if (changedProperties.has("value")) this.syncRows();
|
|
289
|
+
if (changedProperties.has("value") || changedProperties.has("disabled")) this.syncRows();
|
|
288
290
|
this.setAttribute("role", "listbox");
|
|
289
291
|
this.setAttribute("aria-multiselectable", String(this.multiple));
|
|
290
292
|
if (this.disabled) this.setAttribute("aria-disabled", "true");
|
package/package.json
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c2n/list",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/list.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"types": "./types/src/list.d.ts",
|
|
9
|
+
"default": "./dist/list.js"
|
|
10
|
+
},
|
|
11
|
+
"./react": {
|
|
12
|
+
"types": "./react.d.ts",
|
|
13
|
+
"default": "./react.js"
|
|
14
|
+
},
|
|
15
|
+
"./vue": {
|
|
16
|
+
"types": "./vue.d.ts",
|
|
17
|
+
"default": "./vue.js"
|
|
10
18
|
},
|
|
11
19
|
"./custom-elements.json": "./custom-elements.json"
|
|
12
20
|
},
|
|
13
21
|
"files": [
|
|
14
22
|
"dist",
|
|
15
|
-
"types"
|
|
23
|
+
"types",
|
|
24
|
+
"react.d.ts",
|
|
25
|
+
"react.js",
|
|
26
|
+
"vue.d.ts",
|
|
27
|
+
"vue.js"
|
|
16
28
|
],
|
|
17
29
|
"keywords": [
|
|
18
30
|
"list",
|
|
@@ -49,13 +61,13 @@
|
|
|
49
61
|
}
|
|
50
62
|
},
|
|
51
63
|
"dependencies": {
|
|
52
|
-
"@c2n/core": "0.0.
|
|
53
|
-
"@c2n/list-item": "0.0.
|
|
64
|
+
"@c2n/core": "0.0.8",
|
|
65
|
+
"@c2n/list-item": "0.0.8",
|
|
54
66
|
"lit": "3.3.3"
|
|
55
67
|
},
|
|
56
68
|
"devDependencies": {
|
|
57
69
|
"@c2n/config": "*"
|
|
58
70
|
},
|
|
59
71
|
"customElements": "custom-elements.json",
|
|
60
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "be59cbccee1d33ca248e39f69b05c0b595ec6c6d"
|
|
61
73
|
}
|
package/react.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// JSX types for the custom elements of @c2n/list. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/list/react'
|
|
6
|
+
//
|
|
7
|
+
// Register the elements at module scope before React renders, or React writes an object prop as an
|
|
8
|
+
// attribute and it stringifies.
|
|
9
|
+
|
|
10
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
11
|
+
import type { List } from '@c2n/list'
|
|
12
|
+
|
|
13
|
+
/** Standard React host-element attributes plus the element's own public properties. */
|
|
14
|
+
type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
|
|
15
|
+
|
|
16
|
+
declare module 'react' {
|
|
17
|
+
namespace JSX {
|
|
18
|
+
interface IntrinsicElements {
|
|
19
|
+
'c2-list': C2Props<List>
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {}
|
package/react.js
ADDED
package/types/src/list.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { LitElement, type PropertyValueMap } from 'lit';
|
|
2
|
+
import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
|
|
2
3
|
import { ListItem } from '@c2n/list-item';
|
|
3
4
|
export interface SelectionChangeEventDetail {
|
|
4
5
|
value: string[];
|
|
5
6
|
data: unknown[];
|
|
6
7
|
}
|
|
8
|
+
/** Events fired by {@link List}, keyed for `addEventListener`. */
|
|
9
|
+
export interface ListEventMap {
|
|
10
|
+
'selection-change': CustomEvent<SelectionChangeEventDetail>;
|
|
11
|
+
}
|
|
12
|
+
export interface List {
|
|
13
|
+
addEventListener: TypedAddEventListener<List, ListEventMap>;
|
|
14
|
+
removeEventListener: TypedRemoveEventListener<List, ListEventMap>;
|
|
15
|
+
}
|
|
7
16
|
/**
|
|
8
17
|
* A vertical list of `c2-list-item` rows with single or multiple selection. The list owns the selection: it reads the
|
|
9
18
|
* `value` of the clicked row, updates its own `value` (a `;`-separated list in the attribute, an array in the property)
|
|
@@ -20,7 +29,7 @@ export interface SelectionChangeEventDetail {
|
|
|
20
29
|
*
|
|
21
30
|
* @slot default - The rows: `c2-list-item` elements (or wrappers whose first child is a `c2-list-item`), plus `<hr>` dividers and heading elements.
|
|
22
31
|
*
|
|
23
|
-
* @event {CustomEvent<SelectionChangeEventDetail>} selection-change - Fired after the user changes the selection. `detail.value` is the array of selected values, `detail.data` the matching `data` of each row.
|
|
32
|
+
* @event {CustomEvent<SelectionChangeEventDetail>} selection-change - Fired after the user changes the selection. `detail.value` is the array of selected values, `detail.data` the matching `data` of each row. Does not bubble: several components fire `selection-change`, so a listener belongs on the element itself rather than on an ancestor.
|
|
24
33
|
*
|
|
25
34
|
* @cssproperty {color} [--c2-list--background=#ffffff]
|
|
26
35
|
* @cssproperty {pixel} --c2-list--gap
|
package/types/src/list.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,KAAK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AAQ,EAAE,CAItB;IAED,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,mBAAmB;IAS3B,oGAAoG;IACpG,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,aAAa;IA8CrB,OAAO,CAAC,4BAA4B;IAapC,mGAAmG;IACnG,OAAO,CAAC,kBAAkB;cAMP,UAAU,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;cAO3D,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;IAW3E;;OAEG;IACH,cAAc;IAIL,MAAM;CAGhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,IAAI,CAAA;KAChB;CACF"}
|
package/vue.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// Vue template types for the custom elements of @c2n/list. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/list/vue'
|
|
6
|
+
//
|
|
7
|
+
// Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
|
|
8
|
+
// nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
|
|
9
|
+
|
|
10
|
+
import type { DefineComponent, HTMLAttributes } from 'vue'
|
|
11
|
+
import type { List, ListEventMap } from '@c2n/list'
|
|
12
|
+
|
|
13
|
+
/** The element's own public properties, plus every attribute Vue understands on a host element. */
|
|
14
|
+
type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
|
|
15
|
+
|
|
16
|
+
declare module 'vue' {
|
|
17
|
+
interface GlobalComponents {
|
|
18
|
+
'c2-list': DefineComponent<
|
|
19
|
+
C2Props<List> & {
|
|
20
|
+
onSelectionChange?: (event: ListEventMap['selection-change']) => void
|
|
21
|
+
}
|
|
22
|
+
>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module '@vue/runtime-dom' {
|
|
27
|
+
interface HTMLAttributes {
|
|
28
|
+
/** Vue's own definition omits it, and slotting a plain element into a component needs it. */
|
|
29
|
+
slot?: string
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {}
|
package/vue.js
ADDED