@canonical/design-system 0.2.1 → 0.2.3
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.
- package/bun.lock +1 -0
- package/data/concept/Foundations-Grid.ttl +9 -0
- package/data/concept/How-to-differentiate-components-variantsinheritance.ttl +9 -0
- package/data/concept/Indicating-required-fields-in-forms.ttl +9 -0
- package/data/concept/Question-mark-vs-information-icon.ttl +9 -0
- package/data/concepttype/Decision-guide.ttl +5 -0
- package/data/concepttype/Explanation.ttl +5 -0
- package/data/concepttype/How-to-guide.ttl +5 -0
- package/data/concepttype/Mental-model.ttl +5 -0
- package/data/concepttype/Reference.ttl +5 -0
- package/data/concepttype/Tutorial.ttl +5 -0
- package/definitions/ontology.ttl +35 -0
- package/package.json +2 -1
- package/skills/adoption-a1-styles/SKILL.md +54 -1
- package/skills/adoption-a2-components/SKILL.md +48 -1
- package/skills/adoption-a3-forms/SKILL.md +48 -1
- package/skills/anatomy-author/SKILL.md +41 -1
- package/skills/design-auditor/SKILL.md +41 -1
- package/skills/implement-component/SKILL.md +28 -1
- package/skills/specify-component/SKILL.md +38 -1
- package/skills/specify-pattern/SKILL.md +40 -1
- package/source.json +36 -1
- package/src/collect/generateTurtle.tests.ts +148 -0
- package/src/collect/generateTurtle.ts +71 -22
- package/src/collect/types.ts +20 -0
- package/src/config/source.schema.json +27 -0
- package/src/config/types.ts +25 -0
- package/src/transform/rowFilter.tests.ts +100 -0
- package/src/transform/rowFilter.ts +55 -0
- package/src/transform/transform.ts +7 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { RowFilter } from "../config/types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Coerce a normalized cell value to a comparable/measurable string.
|
|
5
|
+
*
|
|
6
|
+
* The provider normalizes lookups to `{ id, name }` and strips whole-value
|
|
7
|
+
* Markdown fences, so a cell is typically a string; a lookup object is reduced
|
|
8
|
+
* to its `name`. Anything else stringifies. Used by the row filter to read the
|
|
9
|
+
* name column and to measure a body column's length.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The raw normalized cell value.
|
|
12
|
+
* @returns The cell as a trimmed string ("" for null/undefined).
|
|
13
|
+
*/
|
|
14
|
+
function cellText(value: unknown): string {
|
|
15
|
+
if (value === null || value === undefined) return "";
|
|
16
|
+
if (typeof value === "string") return value.trim();
|
|
17
|
+
if (
|
|
18
|
+
typeof value === "object" &&
|
|
19
|
+
"name" in (value as Record<string, unknown>)
|
|
20
|
+
) {
|
|
21
|
+
const name = (value as { name?: unknown }).name;
|
|
22
|
+
return typeof name === "string" ? name.trim() : "";
|
|
23
|
+
}
|
|
24
|
+
return String(value).trim();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether a row passes a table's {@link RowFilter} (logical AND over every
|
|
29
|
+
* declared condition). A row is kept when every condition holds; an absent
|
|
30
|
+
* filter keeps every row (the caller guards that case).
|
|
31
|
+
*
|
|
32
|
+
* @param row - The normalized row (column name → cell value).
|
|
33
|
+
* @param filter - The include-filter to apply.
|
|
34
|
+
* @returns True when the row should be emitted.
|
|
35
|
+
*/
|
|
36
|
+
export function rowPassesFilter(
|
|
37
|
+
row: Record<string, unknown>,
|
|
38
|
+
filter: RowFilter,
|
|
39
|
+
): boolean {
|
|
40
|
+
const { nameIn, nonEmpty } = filter;
|
|
41
|
+
|
|
42
|
+
if (nameIn) {
|
|
43
|
+
const actual = cellText(row[nameIn.column]).toLowerCase();
|
|
44
|
+
const wanted = nameIn.values.map((v) => v.trim().toLowerCase());
|
|
45
|
+
if (!wanted.includes(actual)) return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (nonEmpty) {
|
|
49
|
+
for (const { column, minLength } of nonEmpty) {
|
|
50
|
+
if (cellText(row[column]).length < (minLength ?? 1)) return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { TransformConfig } from "../config/types.js";
|
|
|
2
2
|
import { GraphStore, PrefixMap } from "../graph/index.js";
|
|
3
3
|
import expectedTables from "./expectedTables.js";
|
|
4
4
|
import resolveReferences from "./resolveReferences.js";
|
|
5
|
+
import { rowPassesFilter } from "./rowFilter.js";
|
|
5
6
|
import transformRow from "./transformRow.js";
|
|
6
7
|
import type {
|
|
7
8
|
InlineDataMap,
|
|
@@ -116,9 +117,14 @@ export default function transform(
|
|
|
116
117
|
prefixes.add(prefix, namespace);
|
|
117
118
|
}
|
|
118
119
|
|
|
119
|
-
// Transform each row
|
|
120
|
+
// Transform each row, skipping any excluded by an optional include-filter
|
|
121
|
+
// (e.g. Concepts narrowed to the named, non-empty subset).
|
|
122
|
+
const { rowFilter } = tableConfig;
|
|
120
123
|
let subjectCount = 0;
|
|
121
124
|
for (const row of tableData) {
|
|
125
|
+
if (rowFilter && !rowPassesFilter(row, rowFilter)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
122
128
|
const subjectUri = transformRow(
|
|
123
129
|
row,
|
|
124
130
|
tableConfig,
|