From 28e3c75ff407c7e20575b4e6f4bed2eb9d0b5405 Mon Sep 17 00:00:00 2001 From: Wendelin Date: Wed, 14 May 2025 17:21:49 +0200 Subject: [PATCH] Add cli to package.json --- build-scripts/gulp/gallery.js | 2 - custom-elements.json | 186 ++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 custom-elements.json diff --git a/build-scripts/gulp/gallery.js b/build-scripts/gulp/gallery.js index c6c498f136..e54bbfdca8 100644 --- a/build-scripts/gulp/gallery.js +++ b/build-scripts/gulp/gallery.js @@ -17,8 +17,6 @@ import "./translations.js"; import "./rspack.js"; gulp.task("generate-component-docs", async function generateComponentDocs() { - // npx @custom-elements-manifest/analyzer analyze --litelement --globs "src/components/ha-alert.ts --dev" - const filePaths = ["src/components/ha-alert.ts"]; const modules = await Promise.all( diff --git a/custom-elements.json b/custom-elements.json new file mode 100644 index 0000000000..aaae945d74 --- /dev/null +++ b/custom-elements.json @@ -0,0 +1,186 @@ +{ + "schemaVersion": "1.0.0", + "readme": "", + "modules": [ + { + "kind": "javascript-module", + "path": "src/components/ha-alert.ts", + "declarations": [ + { + "kind": "class", + "description": "A custom alert component for displaying messages with various alert types.", + "name": "HaAlert", + "cssProperties": [ + { + "description": "The color used for \"info\" alerts.", + "name": "--info-color" + }, + { + "description": "The color used for \"warning\" alerts.", + "name": "--warning-color" + }, + { + "description": "The color used for \"error\" alerts.", + "name": "--error-color" + }, + { + "description": "The color used for \"success\" alerts.", + "name": "--success-color" + }, + { + "description": "The primary text color used in the alert.", + "name": "--primary-text-color" + } + ], + "cssParts": [ + { + "description": "The container for the alert.", + "name": "issue-type" + }, + { + "description": "The container for the alert icon.", + "name": "icon" + }, + { + "description": "The container for the alert content.", + "name": "content" + }, + { + "description": "The container for the alert actions.", + "name": "action" + }, + { + "description": "The container for the alert title.", + "name": "title" + } + ], + "slots": [ + { + "description": "The main content of the alert.", + "name": "" + }, + { + "description": "Slot for providing a custom icon for the alert.", + "name": "icon" + }, + { + "description": "Slot for providing custom actions or buttons for the alert.", + "name": "action" + } + ], + "members": [ + { + "kind": "field", + "name": "title", + "type": { + "text": "string" + }, + "privacy": "public", + "default": "\"\"", + "description": "The title of the alert. Defaults to an empty string.", + "attribute": "title" + }, + { + "kind": "field", + "name": "alertType", + "type": { + "text": "\"info\" | \"warning\" | \"error\" | \"success\"" + }, + "privacy": "public", + "default": "\"info\"", + "description": "The type of alert to display. Defaults to \"info\". Determines the styling and icon used.", + "attribute": "alert-type" + }, + { + "kind": "field", + "name": "dismissable", + "type": { + "text": "boolean" + }, + "privacy": "public", + "default": "false", + "description": "Whether the alert can be dismissed. Defaults to `false`. If `true`, a dismiss button is displayed.", + "attribute": "dismissable" + }, + { + "kind": "field", + "name": "narrow", + "type": { + "text": "boolean" + }, + "privacy": "public", + "default": "false", + "description": "Whether the alert should use a narrow layout. Defaults to `false`.", + "attribute": "narrow" + }, + { + "kind": "method", + "name": "_dismissClicked", + "privacy": "private" + } + ], + "events": [ + { + "description": "Fired when the dismiss button is clicked.", + "name": "alert-dismissed-clicked" + } + ], + "attributes": [ + { + "name": "title", + "type": { + "text": "string" + }, + "default": "\"\"", + "description": "The title of the alert. Defaults to an empty string.", + "fieldName": "title" + }, + { + "name": "alert-type", + "type": { + "text": "\"info\" | \"warning\" | \"error\" | \"success\"" + }, + "default": "\"info\"", + "description": "The type of alert to display. Defaults to \"info\". Determines the styling and icon used.", + "fieldName": "alertType" + }, + { + "name": "dismissable", + "type": { + "text": "boolean" + }, + "default": "false", + "description": "Whether the alert can be dismissed. Defaults to `false`. If `true`, a dismiss button is displayed.", + "fieldName": "dismissable" + }, + { + "name": "narrow", + "type": { + "text": "boolean" + }, + "default": "false", + "description": "Whether the alert should use a narrow layout. Defaults to `false`.", + "fieldName": "narrow" + } + ], + "superclass": { + "name": "LitElement", + "package": "lit" + }, + "tagName": "ha-alert", + "customElement": true + } + ], + "exports": [ + { + "kind": "custom-element-definition", + "name": "ha-alert", + "declaration": { + "name": "HaAlert", + "module": "src/components/ha-alert.ts" + } + } + ] + } + ] +} diff --git a/package.json b/package.json index b9ab3f2d60..97ea0a572d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "postpack": "pinst --enable", "test": "vitest run --config test/vitest.config.ts", "test:coverage": "vitest run --config test/vitest.config.ts --coverage", + "analyze": "cem analyze --litelement --globs \"src/components/ha-alert.ts\" --dev", "doc": "gulp generate-component-docs" }, "author": "Paulus Schoutsen (http://paulusschoutsen.nl)",