@vectoriox/iox-ui 5.192.0 → 5.194.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/fesm2022/vectoriox-iox-ui-forms-core.mjs +186 -122
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +193 -95
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-seo-core.mjs +37 -11
- package/fesm2022/vectoriox-iox-ui-seo-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +249 -146
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +17 -2
- package/harness-core/index.d.ts +102 -12
- package/index.d.ts +20 -6
- package/package.json +1 -1
- package/seo-core/index.d.ts +8 -1
- package/src/forms-core/messages.ts +72 -1
- package/src/forms-core/submit-lifecycle.ts +4 -5
- package/src/harness-core/business-types.ts +14 -9
- package/src/harness-core/harness-spec.generated.ts +168 -84
- package/src/harness-core/lint.ts +29 -11
- package/src/seo-core/redirects.ts +35 -9
package/src/harness-core/lint.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AnimateId, DesignChoices, DesignMotion, parseHexColor, rgbToOklab, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
1
|
+
import { AnimateId, DesignChoices, DesignMotion, languageOf, parseHexColor, rgbToOklab, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
import type { FactKey } from '@vectoriox/iox-ui/generation-core';
|
|
3
3
|
|
|
4
|
-
import { AvoidCheck, BUSINESS_TYPES, BusinessType, COPY_LENGTH_ORDER, CopyLength, isLookRule } from './business-types';
|
|
4
|
+
import { AvoidCheck, BUSINESS_TYPES, BusinessType, COPY_LENGTH_ORDER, CopyLength, isLookRule, RuleLine } from './business-types';
|
|
5
5
|
import { lookMatches } from './look';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -19,9 +19,23 @@ export enum LintKind {
|
|
|
19
19
|
export interface LintFinding {
|
|
20
20
|
kind: LintKind;
|
|
21
21
|
say: string;
|
|
22
|
+
/** The same line in Hebrew (vectoriox/iox-cms-client#128). Read through `lintSentence`. */
|
|
23
|
+
sayHe: string;
|
|
22
24
|
fact?: FactKey;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* A finding's line in the reader's language — THE choice Home, the Publish dialog and anything else showing advice make:
|
|
29
|
+
* Hebrew (`he`, `he-IL`, the old `iw`) reads `sayHe`, every other language the English `say`. A finding from an older
|
|
30
|
+
* server, without `sayHe`, says its English.
|
|
31
|
+
*/
|
|
32
|
+
export function lintSentence(finding: Pick<LintFinding, 'say'> & Partial<Pick<LintFinding, 'sayHe'>>, lang?: string | null): string {
|
|
33
|
+
const language = languageOf(lang);
|
|
34
|
+
return (language === 'he' || language === 'iw') && finding.sayHe ? finding.sayHe : finding.say;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const line = (kind: LintKind, rule: RuleLine): LintFinding => ({ kind, say: rule.say, sayHe: rule.sayHe });
|
|
38
|
+
|
|
25
39
|
/** What the lint reads of a site. */
|
|
26
40
|
export interface LintSite {
|
|
27
41
|
design: Pick<DesignChoices, 'flavorId' | 'seed' | 'motion' | 'density' | 'mode'> & Partial<Pick<DesignChoices, 'tint'>> & Partial<DesignMotion>;
|
|
@@ -59,36 +73,40 @@ export function lintDesign(site: LintSite, typeId: string, types: ReadonlyArray<
|
|
|
59
73
|
const all = site.allPatterns ?? home;
|
|
60
74
|
for (const rule of type.avoid) {
|
|
61
75
|
if (isLookRule(rule)) {
|
|
62
|
-
if (lookMatches(rule.when, site.design, site.moods ?? [])) out.push(
|
|
76
|
+
if (lookMatches(rule.when, site.design, site.moods ?? [])) out.push(line(LintKind.Look, rule));
|
|
63
77
|
continue;
|
|
64
78
|
}
|
|
65
79
|
switch (rule.check) {
|
|
66
80
|
case AvoidCheck.NeedsFamily:
|
|
67
|
-
if (!home.some(id => familyOf(id) === rule.family)) out.push(
|
|
81
|
+
if (!home.some(id => familyOf(id) === rule.family)) out.push(line(LintKind.Content, rule));
|
|
68
82
|
break;
|
|
69
83
|
case AvoidCheck.NeedsFact:
|
|
70
|
-
if (!site.facts?.[rule.fact]) out.push({
|
|
84
|
+
if (!site.facts?.[rule.fact]) out.push({ ...line(LintKind.Fact, rule), fact: rule.fact });
|
|
71
85
|
break;
|
|
72
86
|
case AvoidCheck.ImageHero:
|
|
73
|
-
if (!site.heroHasImage) out.push(
|
|
87
|
+
if (!site.heroHasImage) out.push(line(LintKind.Content, rule));
|
|
74
88
|
break;
|
|
75
89
|
case AvoidCheck.NoPattern:
|
|
76
|
-
if (all.includes(rule.pattern)) out.push(
|
|
90
|
+
if (all.includes(rule.pattern)) out.push(line(LintKind.Content, rule));
|
|
77
91
|
break;
|
|
78
92
|
case AvoidCheck.CopyLength:
|
|
79
|
-
if (site.copyLength && COPY_LENGTH_ORDER.indexOf(site.copyLength) > COPY_LENGTH_ORDER.indexOf(rule.max)) out.push(
|
|
93
|
+
if (site.copyLength && COPY_LENGTH_ORDER.indexOf(site.copyLength) > COPY_LENGTH_ORDER.indexOf(rule.max)) out.push(line(LintKind.Content, rule));
|
|
80
94
|
break;
|
|
81
95
|
case AvoidCheck.BrandHue: {
|
|
82
96
|
const hue = oklchHue(site.design.seed);
|
|
83
|
-
if (hue && hue.chroma >= rule.minChroma && hue.hue >= rule.from && hue.hue <= rule.to) out.push(
|
|
97
|
+
if (hue && hue.chroma >= rule.minChroma && hue.hue >= rule.from && hue.hue <= rule.to) out.push(line(LintKind.Look, rule));
|
|
84
98
|
break;
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
102
|
const advice = motionAdvice(type.id, site.design.animate, types);
|
|
89
103
|
if (advice) {
|
|
90
|
-
const usual = (SPEC_AXES.animations as Readonly<Record<string, { label: string }>>)[advice.usual]
|
|
91
|
-
out.push({
|
|
104
|
+
const usual = (SPEC_AXES.animations as Readonly<Record<string, { label: string; he: string }>>)[advice.usual];
|
|
105
|
+
out.push({
|
|
106
|
+
kind: LintKind.Look,
|
|
107
|
+
say: `${type.label} sites usually move less (${usual.label}); this much movement as people scroll can feel restless.`,
|
|
108
|
+
sayHe: `באתר של ${type.he} בדרך כלל יש פחות תנועה (${usual.he}); כל כך הרבה תנועה בזמן הגלילה עלולה להרגיש חסרת מנוחה.`,
|
|
109
|
+
});
|
|
92
110
|
}
|
|
93
111
|
return out;
|
|
94
112
|
}
|
|
@@ -98,25 +98,51 @@ function bind(pattern: string, path: string): Record<string, string> | null {
|
|
|
98
98
|
return values;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
export function matchRedirect(redirects: ReadonlyArray<SiteRedirect>, path: string): { to: string; code: number } | null {
|
|
106
|
-
const at = redirectPath(path);
|
|
107
|
-
if (!at) return null;
|
|
101
|
+
/** The redirect that answers `at` (already a redirect path) and where it sends it: an exact `from` first, then the first
|
|
102
|
+
* pattern that matches, its `:name` values put into `to`. */
|
|
103
|
+
function hop<R extends Pick<SiteRedirect, 'from' | 'to'>>(redirects: ReadonlyArray<R>, at: string): { redirect: R; to: string } | null {
|
|
108
104
|
const exact = redirects.find(r => !segmentsOf(r.from).some(isParam) && redirectPath(r.from) === at);
|
|
109
|
-
if (exact) return {
|
|
105
|
+
if (exact) return { redirect: exact, to: exact.to };
|
|
110
106
|
for (const r of redirects) {
|
|
111
107
|
if (!segmentsOf(r.from).some(isParam)) continue;
|
|
112
108
|
const values = bind(r.from, at);
|
|
113
109
|
if (!values) continue;
|
|
114
110
|
const to = segmentsOf(r.to).map(s => (isParam(s) ? values[s] ?? s : s)).join('/');
|
|
115
|
-
return { to: `/${to}
|
|
111
|
+
return { redirect: r, to: `/${to}` };
|
|
116
112
|
}
|
|
117
113
|
return null;
|
|
118
114
|
}
|
|
119
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The redirect a request for `path` follows, or null: an exact `from` first, then the first pattern that matches, its
|
|
118
|
+
* `:name` values put into `to`. ONE hop — what `to` answers is the next request's business.
|
|
119
|
+
*/
|
|
120
|
+
export function matchRedirect(redirects: ReadonlyArray<SiteRedirect>, path: string): { to: string; code: number } | null {
|
|
121
|
+
const at = redirectPath(path);
|
|
122
|
+
if (!at) return null;
|
|
123
|
+
const found = hop(redirects, at);
|
|
124
|
+
return found ? { to: found.to, code: found.redirect.code } : null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Where a visitor sent to `to` finally lands, or null when `to` is no redirect's `from` (nothing to follow) or the chain
|
|
129
|
+
* comes back on itself (no end to offer). The owner's dialog offers it when a new redirect is refused as a chain
|
|
130
|
+
* (`RedirectRefusal.Loop`): "send it to /about instead" (X9-D8). Follows every hop, exact before pattern, the same match
|
|
131
|
+
* the engine makes — the offer is judged again by `redirectRefusal` before it is shown.
|
|
132
|
+
*/
|
|
133
|
+
export function redirectChainEnd(redirects: ReadonlyArray<Pick<SiteRedirect, 'from' | 'to'>>, to: string): string | null {
|
|
134
|
+
let at = redirectPath(to);
|
|
135
|
+
if (!at) return null;
|
|
136
|
+
const seen = new Set<string>([at]);
|
|
137
|
+
for (let found = hop(redirects, at); found; found = hop(redirects, at)) {
|
|
138
|
+
const next = redirectPath(found.to);
|
|
139
|
+
if (!next || seen.has(next)) return null;
|
|
140
|
+
seen.add(next);
|
|
141
|
+
at = next;
|
|
142
|
+
}
|
|
143
|
+
return seen.size > 1 ? at : null;
|
|
144
|
+
}
|
|
145
|
+
|
|
120
146
|
/** What a new redirect is judged against: the site's page routes (`/work/:slug` included) and the redirects it has. */
|
|
121
147
|
export interface RedirectContext {
|
|
122
148
|
pageRoutes: ReadonlyArray<string>;
|