@tristan2828/ui-foundation 4.70.0 → 4.72.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/conventions/docs/add-an-entity.md +107 -21
- package/conventions/docs/cell-patterns.md +210 -37
- package/conventions/docs/design-language.md +52 -24
- package/dist/components/app/edit-in-place-controls.d.ts +34 -0
- package/dist/components/app/edit-in-place-controls.js +92 -0
- package/dist/components/app/edit-in-place-presets.d.ts +187 -0
- package/dist/components/app/edit-in-place-presets.js +409 -0
- package/dist/components/app/edit-in-place-store.d.ts +9 -0
- package/dist/components/app/edit-in-place-store.js +14 -7
- package/dist/components/app/edit-in-place.d.ts +101 -4
- package/dist/components/app/editable-list.js +158 -23
- package/dist/components/app/editable-value.d.ts +2 -2
- package/dist/components/app/editable-value.js +7 -3
- package/dist/components/app/entity-view.d.ts +6 -2
- package/dist/components/app/entity-view.js +11 -2
- package/dist/components/app/record-dialog.d.ts +10 -1
- package/dist/components/app/record-dialog.js +32 -4
- package/dist/components/app/row-edit-cells.d.ts +9 -0
- package/dist/components/app/row-edit-cells.js +12 -16
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/lib/link-href.d.ts +28 -0
- package/dist/lib/link-href.js +40 -0
- package/package.json +1 -1
package/dist/lib/link-href.js
CHANGED
|
@@ -32,3 +32,43 @@ export function linkHref(typed) {
|
|
|
32
32
|
export function linkRefusal(typed) {
|
|
33
33
|
return /\s/.test(typed.trim()) ? 'whitespace' : 'scheme';
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The rule for a link field, shaped as a schema (`safeParse`): what was
|
|
37
|
+
* typed becomes the address to save (`linkHref`: `example.com` gains
|
|
38
|
+
* https://), or `null` for a blank box; another scheme (`javascript:`) or
|
|
39
|
+
* a space inside the address is refused with the words to show. LinkCell
|
|
40
|
+
* and the `inPlace.link` preset check with it.
|
|
41
|
+
*/
|
|
42
|
+
export const linkRule = {
|
|
43
|
+
safeParse(value) {
|
|
44
|
+
const typed = String(value ?? '');
|
|
45
|
+
const href = linkHref(typed);
|
|
46
|
+
if (href === '')
|
|
47
|
+
return { success: true, data: null };
|
|
48
|
+
if (href === null) {
|
|
49
|
+
const message = linkRefusal(typed) === 'whitespace' ? 'An address has no spaces' : 'Use a web or email address';
|
|
50
|
+
return { success: false, error: { issues: [{ message }] } };
|
|
51
|
+
}
|
|
52
|
+
return { success: true, data: href };
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A link's text when it has no label of its own: the host of a web
|
|
57
|
+
* address (`docs.example.com`), the address of an email link, the path
|
|
58
|
+
* of a link on this site. `href` is one `linkHref` returned.
|
|
59
|
+
*/
|
|
60
|
+
export function linkHost(href) {
|
|
61
|
+
if (/^mailto:/i.test(href))
|
|
62
|
+
return href.slice('mailto:'.length);
|
|
63
|
+
if (/^tel:/i.test(href))
|
|
64
|
+
return href.slice('tel:'.length);
|
|
65
|
+
if (/^https?:\/\//i.test(href)) {
|
|
66
|
+
try {
|
|
67
|
+
return new URL(href).host;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return href.replace(/^https?:\/\//i, '');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return href;
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.72.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|