@joralvmel/cosmos-elements 0.0.0 → 0.2.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.
@@ -0,0 +1,65 @@
1
+ import { type ContractProps, iconContract } from '@joralvmel/cosmos-core';
2
+ import { type IconDefinition } from '@joralvmel/cosmos-icons';
3
+ import { CosmElement } from '../../internal/cosm-element.js';
4
+ type Props = ContractProps<typeof iconContract, 'web', {
5
+ IconDefinition: IconDefinition;
6
+ }>;
7
+ export type CosmIconSize = Exclude<Props['size'], undefined>;
8
+ /**
9
+ * Renders a structured SVG icon as a decorative graphic or a named informative image.
10
+ *
11
+ * @tag cosm-icon
12
+ * @csspart icon - The rendered SVG image.
13
+ * @cssprop --cosm-icon-size - Override the rendered icon width and height.
14
+ */
15
+ export declare class CosmIcon extends CosmElement {
16
+ #private;
17
+ static properties: {
18
+ icon: {
19
+ attribute: boolean;
20
+ };
21
+ size: {
22
+ reflect: boolean;
23
+ converter: {
24
+ fromAttribute: (value: string | null) => string | number | null;
25
+ toAttribute: (value: CosmIconSize) => string;
26
+ };
27
+ };
28
+ stroke: {
29
+ type: StringConstructor;
30
+ };
31
+ fill: {
32
+ type: StringConstructor;
33
+ };
34
+ strokeWidth: {
35
+ type: NumberConstructor;
36
+ attribute: string;
37
+ };
38
+ label: {
39
+ type: StringConstructor;
40
+ };
41
+ decorative: {
42
+ type: BooleanConstructor;
43
+ reflect: boolean;
44
+ };
45
+ };
46
+ static styles: import("lit").CSSResult[];
47
+ icon: Props['icon'];
48
+ size: CosmIconSize;
49
+ stroke: string;
50
+ fill: string;
51
+ strokeWidth: number;
52
+ label: string | undefined;
53
+ decorative: boolean;
54
+ constructor();
55
+ protected updated(): void;
56
+ protected willUpdate(): void;
57
+ protected render(): import("lit-html").TemplateResult<1>;
58
+ }
59
+ declare global {
60
+ interface HTMLElementTagNameMap {
61
+ 'cosm-icon': CosmIcon;
62
+ }
63
+ }
64
+ export {};
65
+ //# sourceMappingURL=cosm-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosm-icon.d.ts","sourceRoot":"","sources":["../../../src/components/icon/cosm-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAI7D,KAAK,KAAK,GAAG,aAAa,CAAC,OAAO,YAAY,EAAE,KAAK,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC;AAC3F,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AA6B7D;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,WAAW;;IACvC,OAAgB,UAAU;;;;;;;uCAKG,MAAM,GAAG,IAAI;qCAIf,YAAY;;;;;;;;;;;;;;;;;;;;MAQrC;IAEF,OAAgB,MAAM,4BAAuB;IAErC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;;cAYT,OAAO;cAcP,UAAU;cAsCV,MAAM;CAmB1B;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
@@ -0,0 +1,137 @@
1
+ import { iconContract } from '@joralvmel/cosmos-core';
2
+ import { isIconDefinition } from '@joralvmel/cosmos-icons';
3
+ import { css, html, nothing } from 'lit';
4
+ import { CosmElement } from '../../internal/cosm-element.js';
5
+ import { define } from '../../internal/define.js';
6
+ import { boxSizing } from '../../internal/styles.js';
7
+ const svgNamespace = 'http://www.w3.org/2000/svg';
8
+ const styles = css `
9
+ :host {
10
+ display: inline-block;
11
+ width: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-md, 20px)));
12
+ height: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-md, 20px)));
13
+ vertical-align: middle;
14
+ }
15
+ :host([size='sm']) {
16
+ width: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-sm, 16px)));
17
+ height: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-sm, 16px)));
18
+ }
19
+ :host([size='lg']) {
20
+ width: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-lg, 24px)));
21
+ height: var(--cosm-icon-size, var(--_cosm-icon-size, var(--cosm-icon-size-lg, 24px)));
22
+ }
23
+ svg {
24
+ display: block;
25
+ width: 100%;
26
+ height: 100%;
27
+ overflow: visible;
28
+ stroke-linecap: round;
29
+ stroke-linejoin: round;
30
+ }
31
+ `;
32
+ /**
33
+ * Renders a structured SVG icon as a decorative graphic or a named informative image.
34
+ *
35
+ * @tag cosm-icon
36
+ * @csspart icon - The rendered SVG image.
37
+ * @cssprop --cosm-icon-size - Override the rendered icon width and height.
38
+ */
39
+ export class CosmIcon extends CosmElement {
40
+ static properties = {
41
+ icon: { attribute: false },
42
+ size: {
43
+ reflect: true,
44
+ converter: {
45
+ fromAttribute: (value) => value !== null && value.trim() !== '' && Number.isFinite(Number(value))
46
+ ? Number(value)
47
+ : value,
48
+ toAttribute: (value) => String(value),
49
+ },
50
+ },
51
+ stroke: { type: String },
52
+ fill: { type: String },
53
+ strokeWidth: { type: Number, attribute: 'stroke-width' },
54
+ label: { type: String },
55
+ decorative: { type: Boolean, reflect: true },
56
+ };
57
+ static styles = [boxSizing, styles];
58
+ constructor() {
59
+ super();
60
+ this.size = iconContract.props.size.default;
61
+ this.stroke = iconContract.props.stroke.default;
62
+ this.fill = iconContract.props.fill.default;
63
+ this.strokeWidth = iconContract.props.strokeWidth.default;
64
+ this.label = undefined;
65
+ this.decorative = iconContract.props.decorative.default;
66
+ }
67
+ updated() {
68
+ const icon = this.#requireIcon();
69
+ if (!icon)
70
+ return;
71
+ const svg = this.renderRoot.querySelector('svg');
72
+ if (!svg)
73
+ return;
74
+ svg.replaceChildren();
75
+ for (const [tag, attributes] of icon.nodes) {
76
+ const node = document.createElementNS(svgNamespace, tag);
77
+ for (const [name, value] of Object.entries(attributes))
78
+ node.setAttribute(name, String(value));
79
+ svg.append(node);
80
+ }
81
+ }
82
+ willUpdate() {
83
+ if (!(typeof this.size === 'number' && Number.isFinite(this.size) && this.size > 0) &&
84
+ this.size !== 'sm' &&
85
+ this.size !== 'md' &&
86
+ this.size !== 'lg')
87
+ throw new TypeError('Icon size must be sm, md, lg or a positive finite number.');
88
+ if (!Number.isFinite(this.strokeWidth) || this.strokeWidth < 0)
89
+ throw new TypeError('Icon strokeWidth must be a nonnegative finite number.');
90
+ for (const paint of [this.stroke, this.fill]) {
91
+ if (typeof paint !== 'string' ||
92
+ !paint.trim() ||
93
+ /url\s*\(|javascript:|[;{}\\]/i.test(paint) ||
94
+ [...paint].some(character => character.charCodeAt(0) < 32) ||
95
+ (typeof CSS !== 'undefined' &&
96
+ typeof CSS.supports === 'function' &&
97
+ !CSS.supports('fill', paint)))
98
+ throw new TypeError('Icon paint must be a supported SVG paint without a URL.');
99
+ }
100
+ if (typeof this.size === 'number')
101
+ this.style.setProperty('--_cosm-icon-size', `${this.size}px`);
102
+ else
103
+ this.style.removeProperty('--_cosm-icon-size');
104
+ }
105
+ #requireIcon() {
106
+ if (this.icon === undefined)
107
+ return undefined;
108
+ if (!isIconDefinition(this.icon)) {
109
+ throw new TypeError('cosm-icon requires a valid IconDefinition in its "icon" property.');
110
+ }
111
+ if (!this.decorative && !this.label?.trim()) {
112
+ throw new TypeError('cosm-icon requires a non-empty "label" when decorative is false.');
113
+ }
114
+ return this.icon;
115
+ }
116
+ render() {
117
+ const icon = this.#requireIcon();
118
+ if (!icon) {
119
+ return html `<span part="error" role="alert">
120
+ cosm-icon requires a valid IconDefinition in its "icon" property.
121
+ </span>`;
122
+ }
123
+ return html `<svg
124
+ part="icon"
125
+ aria-hidden=${this.decorative ? 'true' : nothing}
126
+ role=${this.decorative ? nothing : 'img'}
127
+ aria-label=${this.decorative ? nothing : this.label}
128
+ focusable="false"
129
+ viewBox=${icon.viewBox}
130
+ stroke=${this.stroke}
131
+ fill=${this.fill}
132
+ stroke-width=${this.strokeWidth}
133
+ ></svg>`;
134
+ }
135
+ }
136
+ define('cosm-icon', CosmIcon);
137
+ //# sourceMappingURL=cosm-icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosm-icon.js","sourceRoot":"","sources":["../../../src/components/icon/cosm-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAuB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAKrD,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;CAuBjB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC,MAAM,CAAU,UAAU,GAAG;QAC3B,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC1B,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,SAAS,EAAE;gBACT,aAAa,EAAE,CAAC,KAAoB,EAAE,EAA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AAM,CAAC,CAAC,CAAC,OAAO;aACzC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;mBAC3B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;;gBAEzC,IAAI,CAAC,OAAO;eACb,IAAI,CAAC,MAAM;aACb,IAAI,CAAC,IAAI;qBACD,IAAI,CAAC,WAAW;YACzB,CAAC;IACX,CAAC;;AAGH,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC"}
@@ -288,6 +288,167 @@
288
288
  }
289
289
  }
290
290
  ]
291
+ },
292
+ {
293
+ "kind": "javascript-module",
294
+ "path": "src/components/icon/cosm-icon.ts",
295
+ "declarations": [
296
+ {
297
+ "kind": "class",
298
+ "description": "Renders a structured SVG icon as a decorative graphic or a named informative image.",
299
+ "name": "CosmIcon",
300
+ "cssProperties": [
301
+ {
302
+ "description": "Override the rendered icon width and height.",
303
+ "name": "--cosm-icon-size"
304
+ }
305
+ ],
306
+ "cssParts": [
307
+ {
308
+ "description": "The rendered SVG image.",
309
+ "name": "icon"
310
+ }
311
+ ],
312
+ "members": [
313
+ {
314
+ "kind": "field",
315
+ "name": "icon",
316
+ "privacy": "public",
317
+ "type": {
318
+ "text": "Props['icon']"
319
+ }
320
+ },
321
+ {
322
+ "kind": "field",
323
+ "name": "size",
324
+ "privacy": "public",
325
+ "type": {
326
+ "text": "CosmIconSize"
327
+ },
328
+ "attribute": "size",
329
+ "reflects": true
330
+ },
331
+ {
332
+ "kind": "field",
333
+ "name": "stroke",
334
+ "privacy": "public",
335
+ "type": {
336
+ "text": "string"
337
+ },
338
+ "attribute": "stroke"
339
+ },
340
+ {
341
+ "kind": "field",
342
+ "name": "fill",
343
+ "privacy": "public",
344
+ "type": {
345
+ "text": "string"
346
+ },
347
+ "attribute": "fill"
348
+ },
349
+ {
350
+ "kind": "field",
351
+ "name": "strokeWidth",
352
+ "privacy": "public",
353
+ "type": {
354
+ "text": "number"
355
+ },
356
+ "attribute": "stroke-width"
357
+ },
358
+ {
359
+ "kind": "field",
360
+ "name": "label",
361
+ "privacy": "public",
362
+ "type": {
363
+ "text": "string | undefined"
364
+ },
365
+ "default": "undefined",
366
+ "attribute": "label"
367
+ },
368
+ {
369
+ "kind": "field",
370
+ "name": "decorative",
371
+ "privacy": "public",
372
+ "type": {
373
+ "text": "boolean"
374
+ },
375
+ "attribute": "decorative",
376
+ "reflects": true
377
+ },
378
+ {
379
+ "kind": "method",
380
+ "name": "#requireIcon",
381
+ "privacy": "private",
382
+ "return": {
383
+ "type": {
384
+ "text": "IconDefinition | undefined"
385
+ }
386
+ }
387
+ }
388
+ ],
389
+ "attributes": [
390
+ {
391
+ "name": "size",
392
+ "type": {
393
+ "text": "CosmIconSize"
394
+ },
395
+ "fieldName": "size"
396
+ },
397
+ {
398
+ "name": "stroke",
399
+ "type": {
400
+ "text": "string"
401
+ },
402
+ "fieldName": "stroke"
403
+ },
404
+ {
405
+ "name": "fill",
406
+ "type": {
407
+ "text": "string"
408
+ },
409
+ "fieldName": "fill"
410
+ },
411
+ {
412
+ "name": "stroke-width",
413
+ "type": {
414
+ "text": "number"
415
+ },
416
+ "fieldName": "strokeWidth"
417
+ },
418
+ {
419
+ "name": "label",
420
+ "type": {
421
+ "text": "string | undefined"
422
+ },
423
+ "default": "undefined",
424
+ "fieldName": "label"
425
+ },
426
+ {
427
+ "name": "decorative",
428
+ "type": {
429
+ "text": "boolean"
430
+ },
431
+ "fieldName": "decorative"
432
+ }
433
+ ],
434
+ "superclass": {
435
+ "name": "CosmElement",
436
+ "module": "/src/internal/cosm-element.js"
437
+ },
438
+ "tagName": "cosm-icon",
439
+ "customElement": true
440
+ }
441
+ ],
442
+ "exports": [
443
+ {
444
+ "kind": "js",
445
+ "name": "CosmIcon",
446
+ "declaration": {
447
+ "name": "CosmIcon",
448
+ "module": "src/components/icon/cosm-icon.ts"
449
+ }
450
+ }
451
+ ]
291
452
  }
292
453
  ]
293
454
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type { ButtonPressDetail, PressSource } from '@joralvmel/cosmos-core';
2
2
  export { type ButtonSize, type ButtonTone, type ButtonType, type ButtonVariant, CosmButton, } from './components/button/cosm-button.js';
3
+ export { CosmIcon, type CosmIconSize } from './components/icon/cosm-icon.js';
3
4
  export { CosmElement, type EmitOptions } from './internal/cosm-element.js';
4
5
  export { define } from './internal/define.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,UAAU,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,UAAU,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { CosmButton, } from './components/button/cosm-button.js';
2
+ export { CosmIcon } from './components/icon/cosm-icon.js';
2
3
  export { CosmElement } from './internal/cosm-element.js';
3
4
  export { define } from './internal/define.js';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,UAAU,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,UAAU,GACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAqB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
package/llms.md CHANGED
@@ -62,6 +62,33 @@ Events: `cosm-press` → `ButtonPressDetail`.
62
62
  element.addEventListener('cosm-press', event => console.log(event.detail));
63
63
  </script>
64
64
  ```
65
+ ### `<cosm-icon>`
66
+
67
+ Renders a structured SVG icon. Decorative icons are hidden from assistive technology; informative icons require a text label.
68
+
69
+ | Prop | Type | Default | Description |
70
+ | --- | --- | --- | --- |
71
+ | `icon` | IconDefinition | Required | Structured icon definition, commonly imported from @joralvmel/cosmos-icons. |
72
+ | `size` | 'sm' \| 'md' \| 'lg' \| number | `md` | Semantic size (16, 20 or 24) or a positive finite number in pixels / native units. |
73
+ | `stroke` | string | `currentColor` | Stroke paint; currentColor inherits on web and resolves to the theme foreground on native. |
74
+ | `fill` | string | `none` | Root fill paint. Explicit node fills take precedence. |
75
+ | `strokeWidth` (`stroke-width`) | number | `2` | Finite nonnegative stroke width in SVG viewBox units. |
76
+ | `label` | string | — | Accessible name required when decorative is false. |
77
+ | `decorative` | boolean | `true` | Hides the icon from assistive technology when true. |
78
+
79
+ Events: none.
80
+
81
+ ```html
82
+ <cosm-icon></cosm-icon>
83
+
84
+ <script type="module">
85
+ import '@joralvmel/cosmos-elements/icon';
86
+ import { house } from '@joralvmel/cosmos-icons/house';
87
+
88
+ const element = document.querySelector('cosm-icon');
89
+ element.icon = house;
90
+ </script>
91
+ ```
65
92
 
66
93
  ## Themes
67
94
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joralvmel/cosmos-elements",
3
- "version": "0.0.0",
3
+ "version": "0.2.0",
4
4
  "description": "Cosmos UI Web Components built with Lit: framework-agnostic, themeable and accessible.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -40,6 +40,10 @@
40
40
  "types": "./dist/components/button/cosm-button.d.ts",
41
41
  "default": "./dist/components/button/cosm-button.js"
42
42
  },
43
+ "./icon": {
44
+ "types": "./dist/components/icon/cosm-icon.d.ts",
45
+ "default": "./dist/components/icon/cosm-icon.js"
46
+ },
43
47
  "./custom-elements.json": "./dist/custom-elements.json",
44
48
  "./llms.md": "./llms.md",
45
49
  "./package.json": "./package.json"
@@ -52,7 +56,8 @@
52
56
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
53
57
  },
54
58
  "dependencies": {
55
- "@joralvmel/cosmos-core": "^0.0.0",
59
+ "@joralvmel/cosmos-core": "^0.2.0",
60
+ "@joralvmel/cosmos-icons": "^0.2.0",
56
61
  "lit": "^3.3.3"
57
62
  },
58
63
  "devDependencies": {