@fkui/vue 6.6.0 → 6.7.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.
@@ -1,25 +1,55 @@
1
1
  const { Rule, DOMTokenList } = require("html-validate");
2
2
  const { getDocumentationUrl } = require("./common");
3
3
 
4
+ /**
5
+ * @typedef {import("html-validate").RuleDocumentation} RuleDocumentation
6
+ */
7
+
8
+ /**
9
+ * @typedef {Object} Entry
10
+ * @property {string} name
11
+ * @property {string} [replacement]
12
+ * @property {string} [additionalMessage]
13
+ * @property {string} url
14
+ */
15
+
16
+ /** @type {Entry[]} */
4
17
  const deprecatedClasses = [
5
18
  {
6
19
  name: "navbar",
7
- description:
8
- "`.navbar` and related classes are deprecated and should be replaced with Vue components `FPageHeader` and `FNavigationMenu` or their HTML and style.",
20
+ additionalMessage:
21
+ "It should be replaced with the Vue components `FPageHeader` and `FNavigationMenu`.",
9
22
  url: "/components/page-layout/fpageheader.html",
10
23
  },
11
24
  {
12
25
  name: "button--text",
13
- description:
14
- "`.button--text` class is deprecated and should be replaced with `button--discrete`",
26
+ replacement: "button--tertiary",
27
+ url: "/components/button.html",
28
+ },
29
+ {
30
+ name: "button--discrete",
31
+ replacement: "button--tertiary",
15
32
  url: "/components/button.html",
16
33
  },
17
34
  ];
18
35
 
36
+ /**
37
+ * @extends {Rule<Entry, void>}
38
+ */
19
39
  class ClassDeprecated extends Rule {
20
- documentation({ description, url }) {
40
+ /**
41
+ * @param {Entry} context
42
+ * @returns {RuleDocumentation}
43
+ */
44
+ documentation(context) {
45
+ const { url, replacement, additionalMessage } = context;
46
+ const message = replacement
47
+ ? `Class \`${context.name}\` is deprecated and should be replaced with \`${replacement}\``
48
+ : `Class \`${context.name}\` is deprecated.`;
21
49
  return {
22
- description,
50
+ description: additionalMessage
51
+ ? `${message}\n\n${additionalMessage}`
52
+ : message,
23
53
  url: getDocumentationUrl(url),
24
54
  };
25
55
  }
@@ -35,16 +65,18 @@ class ClassDeprecated extends Rule {
35
65
  const tokens = new DOMTokenList(event.value, valueLocation);
36
66
 
37
67
  for (const { item, location } of tokens.iterator()) {
38
- for (const deprecatedClass of deprecatedClasses) {
39
- if (deprecatedClass.name !== item) {
68
+ for (const entry of deprecatedClasses) {
69
+ if (entry.name !== item) {
40
70
  continue;
41
71
  }
42
72
 
43
73
  this.report({
44
74
  node: event.target,
45
75
  location,
46
- message: "`.{{ name }}` class is deprecated.",
47
- context: deprecatedClass,
76
+ message: entry.replacement
77
+ ? `class "{{ name }}" is deprecated and replaced with "{{ replacement }}"`
78
+ : `class "{{ name }}" is deprecated`,
79
+ context: entry,
48
80
  });
49
81
  }
50
82
  }
@@ -0,0 +1,73 @@
1
+ const {
2
+ Rule,
3
+ classifyNodeText,
4
+ TextClassification,
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;
@@ -4,6 +4,7 @@ const PreferFIcon = require("./prefer-ficon.rule");
4
4
  const requiredmaxlength = require("./requiredmaxlength.rule");
5
5
  const ftextfieldFormatterValidation = require("./ftextfieldFormatterValidation.rule");
6
6
  const NoTemplateModal = require("./no-template-modal.rule");
7
+ const FInteractiveTableCheckboxDescription = require("./finteractivetable-checkbox-description.rule");
7
8
  const FTableColumnName = require("./ftablecolumn-name.rule");
8
9
 
9
10
  module.exports = {
@@ -11,6 +12,8 @@ module.exports = {
11
12
  "fkui/class-deprecated": classdeprecated,
12
13
  "fkui/prefer-ficon": PreferFIcon,
13
14
  "fkui/required-max-length": requiredmaxlength,
15
+ "fkui/finteractivetable-checkbox-description":
16
+ FInteractiveTableCheckboxDescription,
14
17
  "fkui/ftextfield-formatter-validation": ftextfieldFormatterValidation,
15
18
  "fkui/no-template-modal": NoTemplateModal,
16
19
  "fkui/ftablecolumn-name": FTableColumnName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fkui/vue",
3
- "version": "6.6.0",
3
+ "version": "6.7.1",
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.6.0",
64
- "@fkui/design": "^6.6.0",
65
- "@fkui/logic": "^6.6.0",
63
+ "@fkui/date": "^6.7.0",
64
+ "@fkui/design": "^6.7.1",
65
+ "@fkui/logic": "^6.7.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": "1db311c19765c07c3804cf2b034399cdbb419f46"
82
+ "gitHead": "05d2236591164ac5d328dee0331643d3544df402"
83
83
  }