@mcp-b/wc-support 0.2.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.
- package/LICENSE +21 -0
- package/dist/base/sigvelo-element.d.ts +80 -0
- package/dist/base/sigvelo-element.d.ts.map +1 -0
- package/dist/base/sigvelo-element.js +147 -0
- package/dist/base/sigvelo-element.js.map +1 -0
- package/dist/cem-plugins/type-references.d.ts +64 -0
- package/dist/cem-plugins/type-references.d.ts.map +1 -0
- package/dist/cem-plugins/type-references.js +242 -0
- package/dist/cem-plugins/type-references.js.map +1 -0
- package/dist/events/activate.d.ts +25 -0
- package/dist/events/activate.d.ts.map +1 -0
- package/dist/events/activate.js +25 -0
- package/dist/events/activate.js.map +1 -0
- package/dist/events/animation.d.ts +10 -0
- package/dist/events/animation.d.ts.map +1 -0
- package/dist/events/animation.js +7 -0
- package/dist/events/animation.js.map +1 -0
- package/dist/events/content.d.ts +15 -0
- package/dist/events/content.d.ts.map +1 -0
- package/dist/events/content.js +8 -0
- package/dist/events/content.js.map +1 -0
- package/dist/events/copy.d.ts +25 -0
- package/dist/events/copy.d.ts.map +1 -0
- package/dist/events/copy.js +15 -0
- package/dist/events/copy.js.map +1 -0
- package/dist/events/expand-collapse.d.ts +38 -0
- package/dist/events/expand-collapse.d.ts.map +1 -0
- package/dist/events/expand-collapse.js +37 -0
- package/dist/events/expand-collapse.js.map +1 -0
- package/dist/events/filter.d.ts +13 -0
- package/dist/events/filter.d.ts.map +1 -0
- package/dist/events/filter.js +12 -0
- package/dist/events/filter.js.map +1 -0
- package/dist/events/flip.d.ts +15 -0
- package/dist/events/flip.d.ts.map +1 -0
- package/dist/events/flip.js +13 -0
- package/dist/events/flip.js.map +1 -0
- package/dist/events/form.d.ts +29 -0
- package/dist/events/form.d.ts.map +1 -0
- package/dist/events/form.js +31 -0
- package/dist/events/form.js.map +1 -0
- package/dist/events/include.d.ts +28 -0
- package/dist/events/include.d.ts.map +1 -0
- package/dist/events/include.js +15 -0
- package/dist/events/include.js.map +1 -0
- package/dist/events/index.d.ts +23 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +23 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/intersect.d.ts +15 -0
- package/dist/events/intersect.d.ts.map +1 -0
- package/dist/events/intersect.js +8 -0
- package/dist/events/intersect.js.map +1 -0
- package/dist/events/item.d.ts +18 -0
- package/dist/events/item.d.ts.map +1 -0
- package/dist/events/item.js +13 -0
- package/dist/events/item.js.map +1 -0
- package/dist/events/load.d.ts +25 -0
- package/dist/events/load.d.ts.map +1 -0
- package/dist/events/load.js +24 -0
- package/dist/events/load.js.map +1 -0
- package/dist/events/mutation.d.ts +15 -0
- package/dist/events/mutation.d.ts.map +1 -0
- package/dist/events/mutation.js +8 -0
- package/dist/events/mutation.js.map +1 -0
- package/dist/events/open-close.d.ts +38 -0
- package/dist/events/open-close.d.ts.map +1 -0
- package/dist/events/open-close.js +33 -0
- package/dist/events/open-close.js.map +1 -0
- package/dist/events/page.d.ts +24 -0
- package/dist/events/page.d.ts.map +1 -0
- package/dist/events/page.js +17 -0
- package/dist/events/page.js.map +1 -0
- package/dist/events/progress.d.ts +15 -0
- package/dist/events/progress.d.ts.map +1 -0
- package/dist/events/progress.js +8 -0
- package/dist/events/progress.js.map +1 -0
- package/dist/events/resize.d.ts +15 -0
- package/dist/events/resize.d.ts.map +1 -0
- package/dist/events/resize.js +8 -0
- package/dist/events/resize.js.map +1 -0
- package/dist/events/row.d.ts +19 -0
- package/dist/events/row.d.ts.map +1 -0
- package/dist/events/row.js +8 -0
- package/dist/events/row.js.map +1 -0
- package/dist/events/select.d.ts +16 -0
- package/dist/events/select.d.ts.map +1 -0
- package/dist/events/select.js +8 -0
- package/dist/events/select.js.map +1 -0
- package/dist/events/tabs.d.ts +32 -0
- package/dist/events/tabs.d.ts.map +1 -0
- package/dist/events/tabs.js +21 -0
- package/dist/events/tabs.js.map +1 -0
- package/dist/events/time.d.ts +15 -0
- package/dist/events/time.d.ts.map +1 -0
- package/dist/events/time.js +13 -0
- package/dist/events/time.js.map +1 -0
- package/dist/events/transition.d.ts +10 -0
- package/dist/events/transition.d.ts.map +1 -0
- package/dist/events/transition.js +7 -0
- package/dist/events/transition.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/prefix.d.ts +16 -0
- package/dist/prefix.d.ts.map +1 -0
- package/dist/prefix.js +22 -0
- package/dist/prefix.js.map +1 -0
- package/dist/styles/form-control.styles.d.ts +9 -0
- package/dist/styles/form-control.styles.d.ts.map +1 -0
- package/dist/styles/form-control.styles.js +337 -0
- package/dist/styles/form-control.styles.js.map +1 -0
- package/dist/styles/host.styles.d.ts +4 -0
- package/dist/styles/host.styles.d.ts.map +1 -0
- package/dist/styles/host.styles.js +33 -0
- package/dist/styles/host.styles.js.map +1 -0
- package/dist/utilities/active-element.d.ts +7 -0
- package/dist/utilities/active-element.d.ts.map +1 -0
- package/dist/utilities/active-element.js +16 -0
- package/dist/utilities/active-element.js.map +1 -0
- package/dist/utilities/animate.d.ts +25 -0
- package/dist/utilities/animate.d.ts.map +1 -0
- package/dist/utilities/animate.js +58 -0
- package/dist/utilities/animate.js.map +1 -0
- package/dist/utilities/defined.d.ts +37 -0
- package/dist/utilities/defined.d.ts.map +1 -0
- package/dist/utilities/defined.js +42 -0
- package/dist/utilities/defined.js.map +1 -0
- package/dist/utilities/drag.d.ts +45 -0
- package/dist/utilities/drag.d.ts.map +1 -0
- package/dist/utilities/drag.js +106 -0
- package/dist/utilities/drag.js.map +1 -0
- package/dist/utilities/html.d.ts +5 -0
- package/dist/utilities/html.d.ts.map +1 -0
- package/dist/utilities/html.js +41 -0
- package/dist/utilities/html.js.map +1 -0
- package/dist/utilities/icon-library.d.ts +28 -0
- package/dist/utilities/icon-library.d.ts.map +1 -0
- package/dist/utilities/icon-library.js +36 -0
- package/dist/utilities/icon-library.js.map +1 -0
- package/dist/utilities/index.d.ts +16 -0
- package/dist/utilities/index.d.ts.map +1 -0
- package/dist/utilities/index.js +16 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/library.d.ts +19 -0
- package/dist/utilities/library.d.ts.map +1 -0
- package/dist/utilities/library.js +45 -0
- package/dist/utilities/library.js.map +1 -0
- package/dist/utilities/loader.d.ts +36 -0
- package/dist/utilities/loader.d.ts.map +1 -0
- package/dist/utilities/loader.js +139 -0
- package/dist/utilities/loader.js.map +1 -0
- package/dist/utilities/localize.d.ts +62 -0
- package/dist/utilities/localize.d.ts.map +1 -0
- package/dist/utilities/localize.js +128 -0
- package/dist/utilities/localize.js.map +1 -0
- package/dist/utilities/long-press.d.ts +67 -0
- package/dist/utilities/long-press.d.ts.map +1 -0
- package/dist/utilities/long-press.js +125 -0
- package/dist/utilities/long-press.js.map +1 -0
- package/dist/utilities/math.d.ts +9 -0
- package/dist/utilities/math.d.ts.map +1 -0
- package/dist/utilities/math.js +25 -0
- package/dist/utilities/math.js.map +1 -0
- package/dist/utilities/parse.d.ts +5 -0
- package/dist/utilities/parse.d.ts.map +1 -0
- package/dist/utilities/parse.js +10 -0
- package/dist/utilities/parse.js.map +1 -0
- package/dist/utilities/platform.d.ts +10 -0
- package/dist/utilities/platform.d.ts.map +1 -0
- package/dist/utilities/platform.js +30 -0
- package/dist/utilities/platform.js.map +1 -0
- package/dist/utilities/scroll.d.ts +8 -0
- package/dist/utilities/scroll.d.ts.map +1 -0
- package/dist/utilities/scroll.js +33 -0
- package/dist/utilities/scroll.js.map +1 -0
- package/dist/utilities/search.d.ts +20 -0
- package/dist/utilities/search.d.ts.map +1 -0
- package/dist/utilities/search.js +110 -0
- package/dist/utilities/search.js.map +1 -0
- package/package.json +77 -0
- package/src/themes/sigvelo.css +28 -0
- package/src/themes/utilities.css +115 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a string by removing diacritics, handling Unicode compositions, and converting to lowercase for consistent
|
|
3
|
+
* string comparison.
|
|
4
|
+
*/
|
|
5
|
+
function normalize(str) {
|
|
6
|
+
return str
|
|
7
|
+
.normalize("NFD") // Decompose characters and diacritics
|
|
8
|
+
.replace(/[\u0300-\u036f]/g, "") // Remove diacritical marks
|
|
9
|
+
.normalize("NFKC") // Normalize to composed form
|
|
10
|
+
.toLocaleLowerCase(); // Make it case-insensitive
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Simple case-insensitive search that checks if a query string appears within content.
|
|
14
|
+
*
|
|
15
|
+
* @param query The search string to look for
|
|
16
|
+
* @param content The string to search within
|
|
17
|
+
* @returns a boolean indicating if the query exists within the content
|
|
18
|
+
*/
|
|
19
|
+
export function exactSearch(query, content) {
|
|
20
|
+
return normalize(content).includes(normalize(query));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Fuzzy string matching that handles typos, transpositions, and works with any language/script. The higher the
|
|
24
|
+
* threshold (0-1), the pickier it is about matches. 0.7 is a good default that catches most typos while avoiding false
|
|
25
|
+
* positives.
|
|
26
|
+
*
|
|
27
|
+
* @param query The search query to look for
|
|
28
|
+
* @param content The string to search within
|
|
29
|
+
* @param threshold Minimum similarity threshold (0-1), where 1 requires exact match
|
|
30
|
+
* @returns a boolean indicating if the fuzzy match meets the threshold
|
|
31
|
+
*/
|
|
32
|
+
export function fuzzySearch(query, content, threshold = 0.7) {
|
|
33
|
+
if (!content || !query)
|
|
34
|
+
return false;
|
|
35
|
+
if (threshold < 0 || threshold > 1)
|
|
36
|
+
throw new Error("Threshold must be between 0 and 1");
|
|
37
|
+
if (query.length > content.length)
|
|
38
|
+
return false;
|
|
39
|
+
// Normalize strings to handle different Unicode compositions, diacritics, etc.
|
|
40
|
+
const normalizedContent = normalize(content);
|
|
41
|
+
const normalizedQuery = normalize(query);
|
|
42
|
+
// Convert to lowercase with proper Unicode support
|
|
43
|
+
const lowContent = normalizedContent.toLocaleLowerCase();
|
|
44
|
+
const lowQuery = normalizedQuery.toLocaleLowerCase();
|
|
45
|
+
let score = 0;
|
|
46
|
+
let contentIndex = 0;
|
|
47
|
+
let queryIndex = 0;
|
|
48
|
+
let lastMatchIndex = -1;
|
|
49
|
+
// Split by code point rather than UTF-16 unit so a surrogate pair stays one
|
|
50
|
+
// character. Array.from iterates identically to spread and states the intent.
|
|
51
|
+
const contentChars = Array.from(lowContent);
|
|
52
|
+
const queryChars = Array.from(lowQuery);
|
|
53
|
+
// Track potential transpositions
|
|
54
|
+
let lastSkippedChar = "";
|
|
55
|
+
let lastSkippedIndex = -1;
|
|
56
|
+
// Scan through content looking for query characters in order
|
|
57
|
+
while (contentIndex < contentChars.length && queryIndex < queryChars.length) {
|
|
58
|
+
const currentQueryChar = queryChars[queryIndex];
|
|
59
|
+
const currentContentChar = contentChars[contentIndex];
|
|
60
|
+
if (currentContentChar === currentQueryChar) {
|
|
61
|
+
// Regular match
|
|
62
|
+
if (lastMatchIndex === -1) {
|
|
63
|
+
score += 1;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
score += Math.max(0, 1 - (contentIndex - lastMatchIndex - 1) * 0.1);
|
|
67
|
+
}
|
|
68
|
+
lastMatchIndex = contentIndex;
|
|
69
|
+
queryIndex++;
|
|
70
|
+
lastSkippedChar = "";
|
|
71
|
+
lastSkippedIndex = -1;
|
|
72
|
+
}
|
|
73
|
+
else if (
|
|
74
|
+
// Check for transposition with next character
|
|
75
|
+
queryIndex + 1 < queryChars.length &&
|
|
76
|
+
contentIndex + 1 < contentChars.length &&
|
|
77
|
+
currentContentChar === queryChars[queryIndex + 1] &&
|
|
78
|
+
contentChars[contentIndex + 1] === currentQueryChar) {
|
|
79
|
+
// Transposition found - add slightly reduced score
|
|
80
|
+
score += 0.9; // Small penalty for transposition
|
|
81
|
+
lastMatchIndex = contentIndex + 1;
|
|
82
|
+
queryIndex += 2;
|
|
83
|
+
contentIndex++;
|
|
84
|
+
lastSkippedChar = "";
|
|
85
|
+
lastSkippedIndex = -1;
|
|
86
|
+
}
|
|
87
|
+
else if (
|
|
88
|
+
// Check for transposition with previously skipped character
|
|
89
|
+
lastSkippedChar === currentQueryChar &&
|
|
90
|
+
contentIndex - lastSkippedIndex <= 2) {
|
|
91
|
+
// Transposition found with previously skipped character
|
|
92
|
+
score += 0.8; // Slightly larger penalty for non-adjacent transposition
|
|
93
|
+
lastMatchIndex = contentIndex;
|
|
94
|
+
queryIndex++;
|
|
95
|
+
lastSkippedChar = "";
|
|
96
|
+
lastSkippedIndex = -1;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// No match - track this character for potential later transposition
|
|
100
|
+
lastSkippedChar = currentContentChar;
|
|
101
|
+
lastSkippedIndex = contentIndex;
|
|
102
|
+
}
|
|
103
|
+
contentIndex++;
|
|
104
|
+
}
|
|
105
|
+
// Calculate final similarity score
|
|
106
|
+
const maxScore = queryChars.length;
|
|
107
|
+
const similarity = queryIndex === queryChars.length ? score / maxScore : 0;
|
|
108
|
+
return similarity >= threshold;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/utilities/search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG;SACP,SAAS,CAAC,KAAK,CAAC,CAAC,sCAAsC;SACvD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,2BAA2B;SAC3D,SAAS,CAAC,MAAM,CAAC,CAAC,6BAA6B;SAC/C,iBAAiB,EAAE,CAAC,CAAC,2BAA2B;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,OAAe;IACxD,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,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,CAAC;YACrC,gBAAgB,GAAG,YAAY,CAAC;QAClC,CAAC;QACD,YAAY,EAAE,CAAC;IACjB,CAAC;IAED,mCAAmC;IACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC;IACnC,MAAM,UAAU,GAAG,UAAU,KAAK,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,UAAU,IAAI,SAAS,CAAC;AACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-b/wc-support",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Shared base classes, events, utilities, and styles for Sigvelo web component libraries.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/WebMCP-org/design-system.git",
|
|
9
|
+
"directory": "packages/wc-support"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src/themes"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./base/*": {
|
|
23
|
+
"types": "./dist/base/*.d.ts",
|
|
24
|
+
"import": "./dist/base/*.js"
|
|
25
|
+
},
|
|
26
|
+
"./prefix": {
|
|
27
|
+
"types": "./dist/prefix.d.ts",
|
|
28
|
+
"import": "./dist/prefix.js"
|
|
29
|
+
},
|
|
30
|
+
"./events": {
|
|
31
|
+
"types": "./dist/events/index.d.ts",
|
|
32
|
+
"import": "./dist/events/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./events/*": {
|
|
35
|
+
"types": "./dist/events/*.d.ts",
|
|
36
|
+
"import": "./dist/events/*.js"
|
|
37
|
+
},
|
|
38
|
+
"./styles/*": {
|
|
39
|
+
"types": "./dist/styles/*.d.ts",
|
|
40
|
+
"import": "./dist/styles/*.js"
|
|
41
|
+
},
|
|
42
|
+
"./utilities": {
|
|
43
|
+
"types": "./dist/utilities/index.d.ts",
|
|
44
|
+
"import": "./dist/utilities/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./utilities/*": {
|
|
47
|
+
"types": "./dist/utilities/*.d.ts",
|
|
48
|
+
"import": "./dist/utilities/*.js"
|
|
49
|
+
},
|
|
50
|
+
"./cem-plugins/type-references.js": {
|
|
51
|
+
"types": "./dist/cem-plugins/type-references.d.ts",
|
|
52
|
+
"import": "./dist/cem-plugins/type-references.js"
|
|
53
|
+
},
|
|
54
|
+
"./themes/*": "./src/themes/*.css"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@mcp-b/design-tokens": "0.37.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"lit": "^3.3.2",
|
|
64
|
+
"lit-html": "^3.3.2",
|
|
65
|
+
"typescript": "^6.0.3",
|
|
66
|
+
"vitest": "^4.1.10"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"lit": "^3.0.0",
|
|
70
|
+
"lit-html": "^3.0.0"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "node --eval \"require('node:fs').rmSync('dist', { force: true, recursive: true })\" && tsc -p tsconfig.prod.json",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"typecheck": "tsc --noEmit"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@import "@mcp-b/design-tokens";
|
|
2
|
+
|
|
3
|
+
/* Opt-in accent and design-language presets, inert until data-preset or
|
|
4
|
+
data-style is set on the root. Imported after the main tokens so their
|
|
5
|
+
equal-specificity overrides win by order. */
|
|
6
|
+
@import "@mcp-b/design-tokens/color-presets";
|
|
7
|
+
@import "@mcp-b/design-tokens/style-presets";
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Web-component-specific additions
|
|
11
|
+
*
|
|
12
|
+
* The cloak utility reduces FOUCE when using the autoloader. It hides any
|
|
13
|
+
* element with the `sigvelo-cloak` class that has an undefined custom element
|
|
14
|
+
* until all elements are defined or two seconds has elapsed.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.sigvelo-cloak:has(:not(:defined)) {
|
|
18
|
+
animation: 2s step-end sigveloCloakAnimation;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes sigveloCloakAnimation {
|
|
22
|
+
from {
|
|
23
|
+
opacity: 0;
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
opacity: 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
@layer sigvelo-utilities {
|
|
2
|
+
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
//
|
|
4
|
+
// Side label
|
|
5
|
+
//
|
|
6
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
|
|
7
|
+
|
|
8
|
+
/* Side label utility */
|
|
9
|
+
.sigvelo-side-label {
|
|
10
|
+
--label-width: 10ch;
|
|
11
|
+
|
|
12
|
+
display: grid;
|
|
13
|
+
grid: auto / var(--label-width) 1fr;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 0.25em 1em;
|
|
16
|
+
|
|
17
|
+
&::part(label) {
|
|
18
|
+
max-width: none;
|
|
19
|
+
text-align: end;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&::part(description) {
|
|
23
|
+
grid-column-start: 2;
|
|
24
|
+
order: 3;
|
|
25
|
+
margin-block: 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
30
|
+
//
|
|
31
|
+
// Form validation
|
|
32
|
+
//
|
|
33
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
|
|
34
|
+
|
|
35
|
+
/* Valid */
|
|
36
|
+
.sigvelo-user-valid:state(user-valid),
|
|
37
|
+
.sigvelo-force-valid {
|
|
38
|
+
color: var(--sigvelo-color-success-text);
|
|
39
|
+
|
|
40
|
+
&::part(label),
|
|
41
|
+
&::part(description) {
|
|
42
|
+
color: var(--sigvelo-color-success-text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&::part(visual-box),
|
|
46
|
+
&:focus::part(visual-box) {
|
|
47
|
+
border-color: var(--sigvelo-color-success-border);
|
|
48
|
+
outline-color: var(--sigvelo-color-success-border);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Invalid */
|
|
53
|
+
.sigvelo-user-invalid:state(user-invalid),
|
|
54
|
+
.sigvelo-force-invalid {
|
|
55
|
+
color: var(--sigvelo-color-danger-text);
|
|
56
|
+
|
|
57
|
+
&::part(label),
|
|
58
|
+
&::part(description) {
|
|
59
|
+
color: var(--sigvelo-color-danger-text);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&::part(visual-box),
|
|
63
|
+
&:focus::part(visual-box) {
|
|
64
|
+
border-color: var(--sigvelo-color-danger-border);
|
|
65
|
+
outline-color: var(--sigvelo-color-danger-border);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
70
|
+
//
|
|
71
|
+
// Visually hidden
|
|
72
|
+
//
|
|
73
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
|
|
74
|
+
|
|
75
|
+
.sigvelo-vh,
|
|
76
|
+
.sigvelo-vh-focusable:not(:focus-within),
|
|
77
|
+
.sigvelo-vh-label::part(label),
|
|
78
|
+
.sigvelo-vh-description::part(description) {
|
|
79
|
+
position: absolute;
|
|
80
|
+
width: 1px;
|
|
81
|
+
height: 1px;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
clip-path: inset(50%);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
88
|
+
//
|
|
89
|
+
// Light/dark utilities
|
|
90
|
+
//
|
|
91
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Toggle content based on light/dark. Keyed on the design system's theming
|
|
95
|
+
* contract: with no [data-theme] override the document follows the operating
|
|
96
|
+
* system, so the system-preference case has to be stated separately from the
|
|
97
|
+
* two explicit overrides.
|
|
98
|
+
*/
|
|
99
|
+
[data-theme="light"] .sigvelo-if-dark,
|
|
100
|
+
[data-theme="dark"] .sigvelo-if-light {
|
|
101
|
+
display: none !important;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (prefers-color-scheme: dark) {
|
|
105
|
+
:root:not([data-theme="light"]) .sigvelo-if-light {
|
|
106
|
+
display: none !important;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@media not all and (prefers-color-scheme: dark) {
|
|
111
|
+
:root:not([data-theme="dark"]) .sigvelo-if-dark {
|
|
112
|
+
display: none !important;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|