@fkui/vue 6.26.0 → 6.28.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,85 @@
1
+ const { Rule } = require("html-validate/node");
2
+ const { getDocumentationUrl, getSlots } = require("./common");
3
+
4
+ /**
5
+ * @typedef {import("html-validate").RuleDocumentation} RuleDocumentation
6
+ */
7
+
8
+ /**
9
+ * @typedef {Object} Entry
10
+ * @property {string} slot
11
+ * @property {string} component
12
+ * @property {string} [replacement]
13
+ * @property {string} [additionalMessage]
14
+ * @property {string} url
15
+ */
16
+
17
+ /** @type {Entry[]} */
18
+ const deprecatedSlots = [
19
+ {
20
+ slot: "#checkbox-description",
21
+ component: "f-interactive-table",
22
+ replacement: "selectable-description",
23
+ url: "/components/table-and-list/table.html",
24
+ },
25
+ ];
26
+
27
+ /**
28
+ * @param {import("html-validate").ElementReadyEvent} event
29
+ * @returns {boolean}
30
+ */
31
+ function isRelevant(event) {
32
+ return deprecatedSlots
33
+ .map((it) => it.component)
34
+ .includes(event.target.tagName);
35
+ }
36
+
37
+ /**
38
+ * @extends {Rule<Entry, void>}
39
+ */
40
+ class SlotDeprecated extends Rule {
41
+ /**
42
+ * @param {Entry} context
43
+ * @returns {RuleDocumentation}
44
+ */
45
+ documentation(context) {
46
+ const { url, replacement, additionalMessage } = context;
47
+ const message = replacement
48
+ ? `Slot \`${context.slot}\` is deprecated and should be replaced with \`${replacement}\``
49
+ : `Slot \`${context.slot}\` is deprecated.`;
50
+ return {
51
+ description: additionalMessage
52
+ ? `${message}\n\n${additionalMessage}`
53
+ : message,
54
+ url: getDocumentationUrl(url),
55
+ };
56
+ }
57
+
58
+ setup() {
59
+ this.on("element:ready", isRelevant, (event) => {
60
+ const { target } = event;
61
+ const slots = getSlots(target);
62
+ const entries = deprecatedSlots.filter((it) =>
63
+ target.is(it.component),
64
+ );
65
+
66
+ for (const entry of entries) {
67
+ const description = slots[entry.slot];
68
+ if (!description) {
69
+ continue;
70
+ }
71
+
72
+ this.report({
73
+ node: target,
74
+ location: description.location,
75
+ message: entry.replacement
76
+ ? `slot "{{ slot }}" is deprecated and replaced with "{{ replacement }}"`
77
+ : `slot "{{ slot }}" is deprecated`,
78
+ context: entry,
79
+ });
80
+ }
81
+ });
82
+ }
83
+ }
84
+
85
+ module.exports = SlotDeprecated;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fkui/vue",
3
- "version": "6.26.0",
3
+ "version": "6.28.0",
4
4
  "description": "Vue implementation of FKUI components",
5
5
  "keywords": [
6
6
  "fkui",
@@ -60,9 +60,9 @@
60
60
  "unit:watch": "jest --watch"
61
61
  },
62
62
  "peerDependencies": {
63
- "@fkui/date": "^6.26.0",
64
- "@fkui/design": "^6.26.0",
65
- "@fkui/logic": "^6.26.0",
63
+ "@fkui/date": "^6.28.0",
64
+ "@fkui/design": "^6.28.0",
65
+ "@fkui/logic": "^6.28.0",
66
66
  "fk-icons": "^4.30.1",
67
67
  "html-validate": ">= 7.9.0",
68
68
  "vue": "^3.5.0"
@@ -79,5 +79,5 @@
79
79
  "node": ">= 20",
80
80
  "npm": ">= 7"
81
81
  },
82
- "gitHead": "ed75f6ab84a4757eb7b627101948112a967dddfe"
82
+ "gitHead": "fe2ffaeb55b9e9f560cc6f660740bc3480f77cd8"
83
83
  }
@@ -1,73 +0,0 @@
1
- const {
2
- Rule,
3
- TextClassification,
4
- classifyNodeText,
5
- } = require("html-validate/node");
6
- const { getDocumentationUrl } = require("./common");
7
-
8
- /**
9
- * @param {import("html-validate").ElementReadyEvent} event
10
- * @returns {boolean}
11
- */
12
- function isRelevant(event) {
13
- return event.target.is("f-interactive-table");
14
- }
15
-
16
- /**
17
- * @param {import("html-validate").HtmlElement} element
18
- * @returns {string[]}
19
- */
20
- function getSlots(element) {
21
- return Object.fromEntries(
22
- element.childElements
23
- .filter((it) => it.is("template"))
24
- .map((it) => {
25
- const key = it.attributes.find((jt) =>
26
- jt.key.startsWith("#"),
27
- )?.key;
28
- return [key, it];
29
- }),
30
- );
31
- }
32
-
33
- class FInteractiveTableCheckboxDescription extends Rule {
34
- documentation() {
35
- return {
36
- description:
37
- "`#checkbox-description` slot must implemented and non-empty when `selectable` is enabled",
38
- url: getDocumentationUrl("/components/table-and-list/table.html"),
39
- };
40
- }
41
-
42
- setup() {
43
- this.on("element:ready", isRelevant, (event) => {
44
- const { target } = event;
45
- const selectable = target.getAttribute("selectable");
46
- if (!selectable) {
47
- return;
48
- }
49
- const slots = getSlots(target);
50
- const checkboxDescription = slots["#checkbox-description"];
51
- if (!checkboxDescription) {
52
- this.report({
53
- node: target,
54
- location: selectable.keyLocation,
55
- message:
56
- "#checkbox-description slot must be implemented when selectable is enabled",
57
- });
58
- return;
59
- }
60
- const textContent = classifyNodeText(checkboxDescription);
61
- if (textContent === TextClassification.EMPTY_TEXT) {
62
- this.report({
63
- node: checkboxDescription,
64
- location: checkboxDescription.location,
65
- message:
66
- "#checkbox-description cannot be empty when selectable is enabled",
67
- });
68
- }
69
- });
70
- }
71
- }
72
-
73
- module.exports = FInteractiveTableCheckboxDescription;