@m3e/shape 1.0.0-rc.1

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,51 @@
1
+ import { LitElement } from "lit";
2
+ import { ShapeName } from "./ShapeName";
3
+ declare const M3eShapeElement_base: import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor & typeof LitElement;
4
+ /**
5
+ * @summary
6
+ * A shape used to add emphasis and decorative flair.
7
+ *
8
+ * @description
9
+ * The `m3e-shape` component allows you to use abstract shapes thoughtfully to add emphasis and decorative flair,
10
+ * including built-in shape morphing.
11
+ *
12
+ * All shape names are sourced from the Material Shape library: `4-leaf-clover`, `4-sided-cookie`, `6-sided-cookie`,
13
+ * `7-sided-cookie`, `8-leaf-clover`, `9-sided-cookie`, `12-sided-cookie`, `arch`, `arrow`, `boom`, `bun`, `burst`,
14
+ * `circle`, `diamond`, `fan`, `flower`, `gem`, `ghost-ish`, `heart`, `hexagon`, `oval`, `pentagon`, `pill`, `pixel-circle`,
15
+ * `pixel-triangle`, `puffy`, `puffy-diamond`, `semicircle`, `slanted`, `soft-boom`, `soft-burst`, `square`, `sunny`,
16
+ * `triangle`, and `very-sunny`. Refer to the Material Shape library for visual references and details.
17
+ *
18
+ * @example
19
+ * The following example illustrates using the `m3e-shape` component to present the `sunny` shape.
20
+ * ```html
21
+ * <m3e-shape name="sunny"></m3e-shape>
22
+ * ```
23
+ *
24
+ * @tag m3e-shape
25
+ *
26
+ * @slot - Renders the clipped content of the shape.
27
+ *
28
+ * @attr name - The name of the shape.
29
+ *
30
+ * @cssprop --m3e-shape-size - Default size of the shape.
31
+ * @cssprop --m3e-shape-container-color - Container (background) color of the shape.
32
+ * @cssprop --m3e-shape-transition - Transition used to morph between shapes.
33
+ */
34
+ export declare class M3eShapeElement extends M3eShapeElement_base {
35
+ /** The styles of the element. */
36
+ static styles: import("lit").CSSResultGroup[];
37
+ /**
38
+ * The name of the shape.
39
+ * @default null
40
+ */
41
+ name: ShapeName | null;
42
+ /** @inheritdoc */
43
+ protected render(): unknown;
44
+ }
45
+ declare global {
46
+ interface HTMLElementTagNameMap {
47
+ "m3e-shape": M3eShapeElement;
48
+ }
49
+ }
50
+ export {};
51
+ //# sourceMappingURL=ShapeElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeElement.d.ts","sourceRoot":"","sources":["../../src/ShapeElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAKvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;;AAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBACa,eAAgB,SAAQ,oBAAwB;IAC3D,iCAAiC;IACjC,OAAgB,MAAM,iCAAgC;IAEtD;;;OAGG;IAC0B,IAAI,EAAE,SAAS,GAAG,IAAI,CAAQ;IAE3D,kBAAkB;cACC,MAAM,IAAI,OAAO;CAGrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,eAAe,CAAC;KAC9B;CACF"}
@@ -0,0 +1,3 @@
1
+ /** Specifies the possible names of a shape. */
2
+ export type ShapeName = "4-leaf-clover" | "4-sided-cookie" | "6-sided-cookie" | "7-sided-cookie" | "8-leaf-clover" | "9-sided-cookie" | "12-sided-cookie" | "arch" | "arrow" | "boom" | "bun" | "burst" | "circle" | "diamond" | "fan" | "flower" | "gem" | "ghost-ish" | "heart" | "hexagon" | "oval" | "pentagon" | "pill" | "pixel-circle" | "pixel-triangle" | "puffy" | "puffy-diamond" | "semicircle" | "slanted" | "soft-boom" | "soft-burst" | "square" | "sunny" | "triangle" | "very-sunny";
3
+ //# sourceMappingURL=ShapeName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeName.d.ts","sourceRoot":"","sources":["../../src/ShapeName.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,MAAM,GACN,OAAO,GACP,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,SAAS,GACT,KAAK,GACL,QAAQ,GACR,KAAK,GACL,WAAW,GACX,OAAO,GACP,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,cAAc,GACd,gBAAgB,GAChB,OAAO,GACP,eAAe,GACf,YAAY,GACZ,SAAS,GACT,WAAW,GACX,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,UAAU,GACV,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { CSSResultGroup } from "lit";
2
+ /**
3
+ * Name styles for `M3eShapeElement`.
4
+ * @internal
5
+ */
6
+ export declare const ShapeNameStyle: CSSResultGroup;
7
+ //# sourceMappingURL=ShapeNameStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeNameStyle.d.ts","sourceRoot":"","sources":["../../src/ShapeNameStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAa,MAAM,KAAK,CAAC;AAchE;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,cAE5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { CSSResult } from "lit";
2
+ import { ShapeName } from "./ShapeName";
3
+ /**
4
+ * Normalized polygons for each shape.
5
+ * @internal
6
+ */
7
+ export declare const ShapePolygon: Record<ShapeName, CSSResult>;
8
+ //# sourceMappingURL=ShapePolygon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapePolygon.d.ts","sourceRoot":"","sources":["../../src/ShapePolygon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,KAAK,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CA0GrD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { CSSResultGroup } from "lit";
2
+ /**
3
+ * Baseline styles for `M3eShapeElement`.
4
+ * @internal
5
+ */
6
+ export declare const ShapeStyle: CSSResultGroup;
7
+ //# sourceMappingURL=ShapeStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeStyle.d.ts","sourceRoot":"","sources":["../../src/ShapeStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1C;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,cAgCxB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Component design tokens that control the `M3eShapeElement` for all variants.
3
+ * @internal
4
+ */
5
+ export declare const ShapeToken: {
6
+ /** Default size of the shape. */
7
+ readonly size: import("lit").CSSResult;
8
+ /** Container (background) color of the shape. */
9
+ readonly containerColor: import("lit").CSSResult;
10
+ /** Transition used to morph between shapes. */
11
+ readonly transition: import("lit").CSSResult;
12
+ };
13
+ //# sourceMappingURL=ShapeToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShapeToken.d.ts","sourceRoot":"","sources":["../../src/ShapeToken.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB,iCAAiC;;IAGjC,iDAAiD;;IAGjD,+CAA+C;;CAEvC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./ShapeElement";
2
+ export * from "./ShapeName";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,13 @@
1
+ import eslint from "@eslint/js";
2
+ import tseslint from "typescript-eslint";
3
+ import { fileURLToPath } from "url";
4
+ import { dirname } from "path";
5
+
6
+ export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
7
+ languageOptions: {
8
+ parserOptions: {
9
+ project: true,
10
+ tsconfigRootDir: dirname(fileURLToPath(import.meta.url)),
11
+ },
12
+ },
13
+ });
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@m3e/shape",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "Shape for M3E",
5
+ "author": "matraic <matraic@yahoo.com>",
6
+ "license": "MIT",
7
+ "homepage": "https://matraic.github.io/m3e/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/matraic/m3e.git"
11
+ },
12
+ "keywords": [
13
+ "material design",
14
+ "web components",
15
+ "shape",
16
+ "4 leaf clover",
17
+ "4 sided cookie",
18
+ "6 sided cookie",
19
+ "7 sided cookie",
20
+ "8 leaf clover",
21
+ "9 sided cookie",
22
+ "12 sided cookie",
23
+ "arch",
24
+ "arrow",
25
+ "boom",
26
+ "bun",
27
+ "burst",
28
+ "circle",
29
+ "diamond",
30
+ "fan",
31
+ "flower",
32
+ "gem",
33
+ "ghost-ish",
34
+ "heart",
35
+ "hexagon",
36
+ "oval",
37
+ "pentagon",
38
+ "pill",
39
+ "pixel circle",
40
+ "pixel triangle",
41
+ "puffy",
42
+ "puffy diamond",
43
+ "semicircle",
44
+ "slanted",
45
+ "soft boom",
46
+ "soft burst",
47
+ "square",
48
+ "sunny",
49
+ "triangle",
50
+ "very sunny"
51
+ ],
52
+ "main": "dist/index.js",
53
+ "module": "dist/index.js",
54
+ "browser": "dist/index.min.js",
55
+ "unpkg": "dist/index.min.js",
56
+ "types": "dist/src/index.d.ts",
57
+ "type": "module",
58
+ "scripts": {
59
+ "build": "rollup -c",
60
+ "cem": "cem analyze --config cem.config.mjs",
61
+ "lint": "npx eslint ./src",
62
+ "clean": "rimraf dist"
63
+ },
64
+ "peerDependencies": {
65
+ "@m3e/core": "1.0.0-rc.1",
66
+ "lit": "^3.3.0"
67
+ },
68
+ "devDependencies": {
69
+ "@custom-elements-manifest/analyzer": "^0.10.4",
70
+ "@eslint/js": "^9.30.1",
71
+ "@rollup/plugin-node-resolve": "^16.0.0",
72
+ "@rollup/plugin-terser": "^0.4.4",
73
+ "@rollup/plugin-typescript": "12.1.0",
74
+ "custom-element-vs-code-integration": "^1.5.0",
75
+ "eslint": "^9.32.0",
76
+ "rimraf": "^6.0.1",
77
+ "rollup": "^4.44.2",
78
+ "tslib": "^2.8.1",
79
+ "typescript": "~5.8.2",
80
+ "typescript-eslint": "^8.38.0"
81
+ },
82
+ "customElements": "dist/custom-elements.json"
83
+ }
@@ -0,0 +1,32 @@
1
+ import resolve from "@rollup/plugin-node-resolve";
2
+ import terser from "@rollup/plugin-terser";
3
+ import typescript from "@rollup/plugin-typescript";
4
+
5
+ const banner = `/**
6
+ * @license MIT
7
+ * Copyright (c) 2025 matraic
8
+ * See LICENSE file in the project root for full license text.
9
+ */`;
10
+
11
+ export default [
12
+ {
13
+ input: "src/index.ts",
14
+ output: [
15
+ {
16
+ file: "dist/index.js",
17
+ format: "esm",
18
+ sourcemap: true,
19
+ banner: banner,
20
+ },
21
+ {
22
+ file: "dist/index.min.js",
23
+ format: "esm",
24
+ sourcemap: true,
25
+ banner: banner,
26
+ plugins: [terser({ mangle: true })],
27
+ },
28
+ ],
29
+ external: ["@m3e/core", "lit"],
30
+ plugins: [resolve(), typescript()],
31
+ },
32
+ ];
@@ -0,0 +1,61 @@
1
+ import { html, LitElement } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+
4
+ import { Role } from "@m3e/core";
5
+
6
+ import { ShapeName } from "./ShapeName";
7
+ import { ShapeStyle } from "./ShapeStyle";
8
+ import { ShapeNameStyle } from "./ShapeNameStyle";
9
+
10
+ /**
11
+ * @summary
12
+ * A shape used to add emphasis and decorative flair.
13
+ *
14
+ * @description
15
+ * The `m3e-shape` component allows you to use abstract shapes thoughtfully to add emphasis and decorative flair,
16
+ * including built-in shape morphing.
17
+ *
18
+ * All shape names are sourced from the Material Shape library: `4-leaf-clover`, `4-sided-cookie`, `6-sided-cookie`,
19
+ * `7-sided-cookie`, `8-leaf-clover`, `9-sided-cookie`, `12-sided-cookie`, `arch`, `arrow`, `boom`, `bun`, `burst`,
20
+ * `circle`, `diamond`, `fan`, `flower`, `gem`, `ghost-ish`, `heart`, `hexagon`, `oval`, `pentagon`, `pill`, `pixel-circle`,
21
+ * `pixel-triangle`, `puffy`, `puffy-diamond`, `semicircle`, `slanted`, `soft-boom`, `soft-burst`, `square`, `sunny`,
22
+ * `triangle`, and `very-sunny`. Refer to the Material Shape library for visual references and details.
23
+ *
24
+ * @example
25
+ * The following example illustrates using the `m3e-shape` component to present the `sunny` shape.
26
+ * ```html
27
+ * <m3e-shape name="sunny"></m3e-shape>
28
+ * ```
29
+ *
30
+ * @tag m3e-shape
31
+ *
32
+ * @slot - Renders the clipped content of the shape.
33
+ *
34
+ * @attr name - The name of the shape.
35
+ *
36
+ * @cssprop --m3e-shape-size - Default size of the shape.
37
+ * @cssprop --m3e-shape-container-color - Container (background) color of the shape.
38
+ * @cssprop --m3e-shape-transition - Transition used to morph between shapes.
39
+ */
40
+ @customElement("m3e-shape")
41
+ export class M3eShapeElement extends Role(LitElement, "none") {
42
+ /** The styles of the element. */
43
+ static override styles = [ShapeStyle, ShapeNameStyle];
44
+
45
+ /**
46
+ * The name of the shape.
47
+ * @default null
48
+ */
49
+ @property({ reflect: true }) name: ShapeName | null = null;
50
+
51
+ /** @inheritdoc */
52
+ protected override render(): unknown {
53
+ return html`<div class="wrapper"><slot></slot></div>`;
54
+ }
55
+ }
56
+
57
+ declare global {
58
+ interface HTMLElementTagNameMap {
59
+ "m3e-shape": M3eShapeElement;
60
+ }
61
+ }
@@ -0,0 +1,37 @@
1
+ /** Specifies the possible names of a shape. */
2
+ export type ShapeName =
3
+ | "4-leaf-clover"
4
+ | "4-sided-cookie"
5
+ | "6-sided-cookie"
6
+ | "7-sided-cookie"
7
+ | "8-leaf-clover"
8
+ | "9-sided-cookie"
9
+ | "12-sided-cookie"
10
+ | "arch"
11
+ | "arrow"
12
+ | "boom"
13
+ | "bun"
14
+ | "burst"
15
+ | "circle"
16
+ | "diamond"
17
+ | "fan"
18
+ | "flower"
19
+ | "gem"
20
+ | "ghost-ish"
21
+ | "heart"
22
+ | "hexagon"
23
+ | "oval"
24
+ | "pentagon"
25
+ | "pill"
26
+ | "pixel-circle"
27
+ | "pixel-triangle"
28
+ | "puffy"
29
+ | "puffy-diamond"
30
+ | "semicircle"
31
+ | "slanted"
32
+ | "soft-boom"
33
+ | "soft-burst"
34
+ | "square"
35
+ | "sunny"
36
+ | "triangle"
37
+ | "very-sunny";
@@ -0,0 +1,21 @@
1
+ import { css, CSSResult, CSSResultGroup, unsafeCSS } from "lit";
2
+
3
+ import { ShapeName } from "./ShapeName";
4
+ import { ShapePolygon } from "./ShapePolygon";
5
+
6
+ /** @private */
7
+ function shapeStyle(name: ShapeName): CSSResult {
8
+ return css`
9
+ :host([name="${unsafeCSS(name)}"]) .wrapper {
10
+ clip-path: polygon(${ShapePolygon[name]});
11
+ }
12
+ `;
13
+ }
14
+
15
+ /**
16
+ * Name styles for `M3eShapeElement`.
17
+ * @internal
18
+ */
19
+ export const ShapeNameStyle: CSSResultGroup = [
20
+ ...Object.getOwnPropertyNames(ShapePolygon).map((name) => shapeStyle(name as ShapeName)),
21
+ ];