@realiizlabs/admin 0.11.2 → 0.13.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/dist/Sidebar-CNuphww6.d.cts +60 -0
- package/dist/Sidebar-CNuphww6.d.ts +60 -0
- package/dist/auth/index.d.cts +5 -127
- package/dist/auth/index.d.ts +5 -127
- package/dist/auth-ui/index.js +124 -1
- package/dist/auth-ui/index.js.map +1 -1
- package/dist/forms/index.js +287 -1
- package/dist/forms/index.js.map +1 -1
- package/dist/forms-ui/index.js +355 -6
- package/dist/forms-ui/index.js.map +1 -1
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.cts +3 -77
- package/dist/git/index.d.ts +3 -77
- package/dist/git/index.js.map +1 -1
- package/dist/members-nhbRSYyr.d.cts +106 -0
- package/dist/members-nhbRSYyr.d.ts +106 -0
- package/dist/roles-BjWuj2_v.d.cts +25 -0
- package/dist/roles-Dnwj-DAm.d.ts +25 -0
- package/dist/shell/index.d.cts +3 -58
- package/dist/shell/index.d.ts +3 -58
- package/dist/studio/index.cjs +1150 -0
- package/dist/studio/index.cjs.map +1 -0
- package/dist/studio/index.d.cts +325 -0
- package/dist/studio/index.d.ts +325 -0
- package/dist/studio/index.js +1131 -0
- package/dist/studio/index.js.map +1 -0
- package/dist/studio-ui/index.cjs +3931 -0
- package/dist/studio-ui/index.cjs.map +1 -0
- package/dist/studio-ui/index.d.cts +375 -0
- package/dist/studio-ui/index.d.ts +375 -0
- package/dist/studio-ui/index.js +3900 -0
- package/dist/studio-ui/index.js.map +1 -0
- package/dist/types-BP5G1myE.d.cts +78 -0
- package/dist/types-BP5G1myE.d.ts +78 -0
- package/package.json +20 -2
- package/dist/chunk-2GSYBARR.js +0 -126
- package/dist/chunk-2GSYBARR.js.map +0 -1
- package/dist/chunk-JLR5K6RP.js +0 -289
- package/dist/chunk-JLR5K6RP.js.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the git write layer.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is an argument type or a return type. There is no module
|
|
5
|
+
* state anywhere in src/git — every function receives a RepoContext so the
|
|
6
|
+
* token is never read from process.env at import time (BUILD-ENV law) and the
|
|
7
|
+
* caller decides which site's repo it is talking to.
|
|
8
|
+
*/
|
|
9
|
+
/** Which repo, and with what credential. Passed to every function. */
|
|
10
|
+
interface RepoContext {
|
|
11
|
+
owner: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
/**
|
|
14
|
+
* Fine-grained PAT scoped to this one repo. Required permissions (observed in
|
|
15
|
+
* the ADMIN-01 probe): Contents RW, Pull requests RW, Commit statuses R.
|
|
16
|
+
* Lives in the site's server env; never reaches a browser.
|
|
17
|
+
*/
|
|
18
|
+
token: string;
|
|
19
|
+
/** Default branch to branch from and merge into. Defaults to "main". */
|
|
20
|
+
baseBranch?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A utf-8 text file, e.g. an MDX document. Inlined into the tree. */
|
|
23
|
+
interface TextFile {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
encoding?: "utf-8";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A binary file, e.g. an image. Must be uploaded as a blob first — the trees
|
|
30
|
+
* API cannot inline base64 (observed: no `encoding` field on tree entries).
|
|
31
|
+
*/
|
|
32
|
+
interface BinaryFile {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
encoding: "base64";
|
|
36
|
+
}
|
|
37
|
+
type FileInput = TextFile | BinaryFile;
|
|
38
|
+
interface CreateBranchResult {
|
|
39
|
+
branch: string;
|
|
40
|
+
/** The sha of the base branch at the moment the branch was created. */
|
|
41
|
+
baseSha: string;
|
|
42
|
+
}
|
|
43
|
+
interface WriteFilesResult {
|
|
44
|
+
branch: string;
|
|
45
|
+
commitSha: string;
|
|
46
|
+
treeSha: string;
|
|
47
|
+
/** How many files landed in the single commit. */
|
|
48
|
+
fileCount: number;
|
|
49
|
+
}
|
|
50
|
+
interface PullRequest {
|
|
51
|
+
number: number;
|
|
52
|
+
html_url: string;
|
|
53
|
+
headSha: string;
|
|
54
|
+
branch: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Exactly three states. `pending` is the normal condition right after a push
|
|
58
|
+
* and while GitHub is still computing mergeability — never an error.
|
|
59
|
+
*/
|
|
60
|
+
type PullRequestStatus = {
|
|
61
|
+
state: "green";
|
|
62
|
+
warning?: string;
|
|
63
|
+
previewUrl?: string;
|
|
64
|
+
} | {
|
|
65
|
+
state: "red";
|
|
66
|
+
failingCheck: string | null;
|
|
67
|
+
} | {
|
|
68
|
+
state: "pending";
|
|
69
|
+
};
|
|
70
|
+
type MergeResult = {
|
|
71
|
+
merged: true;
|
|
72
|
+
sha: string;
|
|
73
|
+
} | {
|
|
74
|
+
merged: false;
|
|
75
|
+
state: "pending";
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type { BinaryFile as B, CreateBranchResult as C, FileInput as F, MergeResult as M, PullRequest as P, RepoContext as R, TextFile as T, WriteFilesResult as W, PullRequestStatus as a };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the git write layer.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is an argument type or a return type. There is no module
|
|
5
|
+
* state anywhere in src/git — every function receives a RepoContext so the
|
|
6
|
+
* token is never read from process.env at import time (BUILD-ENV law) and the
|
|
7
|
+
* caller decides which site's repo it is talking to.
|
|
8
|
+
*/
|
|
9
|
+
/** Which repo, and with what credential. Passed to every function. */
|
|
10
|
+
interface RepoContext {
|
|
11
|
+
owner: string;
|
|
12
|
+
repo: string;
|
|
13
|
+
/**
|
|
14
|
+
* Fine-grained PAT scoped to this one repo. Required permissions (observed in
|
|
15
|
+
* the ADMIN-01 probe): Contents RW, Pull requests RW, Commit statuses R.
|
|
16
|
+
* Lives in the site's server env; never reaches a browser.
|
|
17
|
+
*/
|
|
18
|
+
token: string;
|
|
19
|
+
/** Default branch to branch from and merge into. Defaults to "main". */
|
|
20
|
+
baseBranch?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A utf-8 text file, e.g. an MDX document. Inlined into the tree. */
|
|
23
|
+
interface TextFile {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
encoding?: "utf-8";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A binary file, e.g. an image. Must be uploaded as a blob first — the trees
|
|
30
|
+
* API cannot inline base64 (observed: no `encoding` field on tree entries).
|
|
31
|
+
*/
|
|
32
|
+
interface BinaryFile {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
encoding: "base64";
|
|
36
|
+
}
|
|
37
|
+
type FileInput = TextFile | BinaryFile;
|
|
38
|
+
interface CreateBranchResult {
|
|
39
|
+
branch: string;
|
|
40
|
+
/** The sha of the base branch at the moment the branch was created. */
|
|
41
|
+
baseSha: string;
|
|
42
|
+
}
|
|
43
|
+
interface WriteFilesResult {
|
|
44
|
+
branch: string;
|
|
45
|
+
commitSha: string;
|
|
46
|
+
treeSha: string;
|
|
47
|
+
/** How many files landed in the single commit. */
|
|
48
|
+
fileCount: number;
|
|
49
|
+
}
|
|
50
|
+
interface PullRequest {
|
|
51
|
+
number: number;
|
|
52
|
+
html_url: string;
|
|
53
|
+
headSha: string;
|
|
54
|
+
branch: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Exactly three states. `pending` is the normal condition right after a push
|
|
58
|
+
* and while GitHub is still computing mergeability — never an error.
|
|
59
|
+
*/
|
|
60
|
+
type PullRequestStatus = {
|
|
61
|
+
state: "green";
|
|
62
|
+
warning?: string;
|
|
63
|
+
previewUrl?: string;
|
|
64
|
+
} | {
|
|
65
|
+
state: "red";
|
|
66
|
+
failingCheck: string | null;
|
|
67
|
+
} | {
|
|
68
|
+
state: "pending";
|
|
69
|
+
};
|
|
70
|
+
type MergeResult = {
|
|
71
|
+
merged: true;
|
|
72
|
+
sha: string;
|
|
73
|
+
} | {
|
|
74
|
+
merged: false;
|
|
75
|
+
state: "pending";
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type { BinaryFile as B, CreateBranchResult as C, FileInput as F, MergeResult as M, PullRequest as P, RepoContext as R, TextFile as T, WriteFilesResult as W, PullRequestStatus as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realiizlabs/admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Reusable component library for Realiiz client websites.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -52,6 +52,16 @@
|
|
|
52
52
|
"types": "./dist/events/index.d.ts",
|
|
53
53
|
"import": "./dist/events/index.js",
|
|
54
54
|
"require": "./dist/events/index.cjs"
|
|
55
|
+
},
|
|
56
|
+
"./studio": {
|
|
57
|
+
"types": "./dist/studio/index.d.ts",
|
|
58
|
+
"import": "./dist/studio/index.js",
|
|
59
|
+
"require": "./dist/studio/index.cjs"
|
|
60
|
+
},
|
|
61
|
+
"./studio-ui": {
|
|
62
|
+
"types": "./dist/studio-ui/index.d.ts",
|
|
63
|
+
"import": "./dist/studio-ui/index.js",
|
|
64
|
+
"require": "./dist/studio-ui/index.cjs"
|
|
55
65
|
}
|
|
56
66
|
},
|
|
57
67
|
"sideEffects": false,
|
|
@@ -68,7 +78,15 @@
|
|
|
68
78
|
"clean": "rm -rf dist"
|
|
69
79
|
},
|
|
70
80
|
"dependencies": {
|
|
71
|
-
"server-only": "^0.0.1"
|
|
81
|
+
"server-only": "^0.0.1",
|
|
82
|
+
"gray-matter": "^4.0.3",
|
|
83
|
+
"unified": "^11.0.5",
|
|
84
|
+
"remark-parse": "^11.0.0",
|
|
85
|
+
"remark-gfm": "^4.0.0",
|
|
86
|
+
"remark-rehype": "^11.1.0",
|
|
87
|
+
"rehype-raw": "^7.0.0",
|
|
88
|
+
"rehype-slug": "^6.0.0",
|
|
89
|
+
"rehype-stringify": "^10.0.0"
|
|
72
90
|
},
|
|
73
91
|
"peerDependencies": {
|
|
74
92
|
"@supabase/ssr": ">=0.5",
|
package/dist/chunk-2GSYBARR.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// src/forms-ui/styles.ts
|
|
2
|
-
var FORM_CSS = `
|
|
3
|
-
.realiiz-form{
|
|
4
|
-
--_fg:var(--realiiz-form-fg,#111);
|
|
5
|
-
--_muted:var(--realiiz-form-muted,#666);
|
|
6
|
-
--_border:var(--realiiz-form-border,#cfcfcf);
|
|
7
|
-
--_accent:var(--realiiz-form-accent,#111);
|
|
8
|
-
--_accent-fg:var(--realiiz-form-accent-fg,#fff);
|
|
9
|
-
--_danger:var(--realiiz-form-danger,#b3261e);
|
|
10
|
-
--_radius:var(--realiiz-form-radius,6px);
|
|
11
|
-
--_font:var(--realiiz-form-font,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);
|
|
12
|
-
--_ring:var(--realiiz-form-focus-ring,0 0 0 3px rgba(0,0,0,.15));
|
|
13
|
-
box-sizing:border-box;max-width:100%;color:var(--_fg);font-family:var(--_font);font-size:15px;line-height:1.4;
|
|
14
|
-
}
|
|
15
|
-
.realiiz-form *,.realiiz-form *::before,.realiiz-form *::after{box-sizing:inherit}
|
|
16
|
-
.realiiz-form fieldset{border:0;margin:0 0 20px;padding:0;min-width:0}
|
|
17
|
-
.realiiz-form legend{font-weight:600;font-size:13px;letter-spacing:.02em;text-transform:uppercase;color:var(--_muted);margin-bottom:12px;padding:0}
|
|
18
|
-
.realiiz-form__field{display:block;margin:0 0 16px}
|
|
19
|
-
.realiiz-form__label{display:block;font-weight:500;margin-bottom:6px}
|
|
20
|
-
.realiiz-form__required{color:var(--_danger);margin-left:3px}
|
|
21
|
-
.realiiz-form__control{display:block;width:100%;max-width:100%;font:inherit;color:inherit;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius);padding:9px 11px;min-height:40px}
|
|
22
|
-
.realiiz-form__control:focus{outline:none;border-color:var(--_accent);box-shadow:var(--_ring)}
|
|
23
|
-
.realiiz-form__control--textarea{min-height:110px;resize:vertical}
|
|
24
|
-
.realiiz-form__control--body{min-height:280px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:14px}
|
|
25
|
-
.realiiz-form__control--invalid{border-color:var(--_danger)}
|
|
26
|
-
.realiiz-select{position:relative}
|
|
27
|
-
.realiiz-select__btn{display:flex;align-items:center;justify-content:space-between;gap:10px;text-align:left;cursor:pointer;background:#fff}
|
|
28
|
-
.realiiz-select__btn svg{flex-shrink:0;color:var(--_muted);transition:transform .15s}
|
|
29
|
-
.realiiz-select__btn--open{border-color:var(--_accent);box-shadow:var(--_ring)}
|
|
30
|
-
.realiiz-select__btn--open svg{transform:rotate(180deg)}
|
|
31
|
-
.realiiz-select__btn:disabled{opacity:.6;cursor:default}
|
|
32
|
-
.realiiz-select__placeholder{color:var(--_muted)}
|
|
33
|
-
.realiiz-select__menu{position:absolute;left:0;right:0;top:calc(100% + 6px);margin:0;padding:6px 0;list-style:none;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius);box-shadow:0 8px 24px rgba(14,23,38,.14);max-height:260px;overflow:auto;z-index:40}
|
|
34
|
-
.realiiz-select__item{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:14px;color:var(--_fg);cursor:pointer}
|
|
35
|
-
.realiiz-select__item--active{background:var(--realiiz-form-hover,rgba(0,0,0,.05))}
|
|
36
|
-
.realiiz-select__item--selected{font-weight:600}
|
|
37
|
-
.realiiz-select__check{width:1em;flex-shrink:0;color:var(--_accent);font-weight:700}
|
|
38
|
-
.realiiz-form__check{display:flex;align-items:center;gap:8px;font-weight:500}
|
|
39
|
-
.realiiz-form__check input{width:18px;height:18px;margin:0}
|
|
40
|
-
.realiiz-form__helper{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:var(--_muted);margin-top:4px;min-height:1em}
|
|
41
|
-
.realiiz-form__count{margin-left:auto;font-variant-numeric:tabular-nums}
|
|
42
|
-
.realiiz-form__error{color:var(--_danger);font-size:13px;margin-top:4px}
|
|
43
|
-
.realiiz-image{border:1px dashed var(--_border);border-radius:var(--_radius);padding:16px 18px;background:#fff;outline:none;transition:border-color .15s}
|
|
44
|
-
.realiiz-image--over{border-color:var(--_accent);border-style:solid}
|
|
45
|
-
.realiiz-image--invalid{border-color:var(--_danger)}
|
|
46
|
-
.realiiz-image--busy{opacity:.7}
|
|
47
|
-
.realiiz-image__empty{display:flex;align-items:center;gap:14px;flex-wrap:wrap;color:var(--_muted)}
|
|
48
|
-
.realiiz-image__icon{flex-shrink:0;color:var(--_muted)}
|
|
49
|
-
.realiiz-image__or{font-size:13px}
|
|
50
|
-
.realiiz-image__has{display:flex;align-items:flex-start;gap:16px}
|
|
51
|
-
.realiiz-image__thumb{display:block;max-height:160px;max-width:min(320px,55%);width:auto;object-fit:cover;border-radius:8px;border:1px solid var(--_border);background:#f6f8fa}
|
|
52
|
-
.realiiz-image__meta{display:flex;flex-direction:column;gap:10px;min-width:0}
|
|
53
|
-
.realiiz-image__detail{font-size:13px;color:var(--_muted);word-break:break-all}
|
|
54
|
-
.realiiz-image__actions{display:flex;align-items:center;gap:14px}
|
|
55
|
-
.realiiz-image__remove{font:inherit;font-size:13px;background:none;border:0;padding:0;color:var(--_muted);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
|
|
56
|
-
.realiiz-image__remove:hover{color:var(--_danger)}
|
|
57
|
-
.realiiz-image__hint{font-size:12px;color:var(--_muted);margin-top:10px}
|
|
58
|
-
.realiiz-image .realiiz-form__error{margin-top:8px}
|
|
59
|
-
@media (max-width:720px){.realiiz-image__has{flex-direction:column}.realiiz-image__thumb{max-width:100%}}
|
|
60
|
-
.realiiz-form__alert{border:1px solid var(--_danger);border-radius:var(--_radius);padding:12px 14px;margin:0 0 20px;color:var(--_danger)}
|
|
61
|
-
.realiiz-form__alert ul{margin:6px 0 0;padding-left:18px}
|
|
62
|
-
.realiiz-form__actions{display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;margin-top:8px}
|
|
63
|
-
.realiiz-form__help{text-decoration:underline dotted;text-decoration-color:color-mix(in srgb,currentColor 45%,transparent);text-underline-offset:4px;cursor:help}
|
|
64
|
-
.realiiz-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
|
65
|
-
.realiiz-form__footer{max-width:920px}
|
|
66
|
-
.realiiz-form__bar{display:flex;align-items:center;gap:10px;margin-top:16px;padding:12px 0;border-top:1px solid var(--_border);background:#fff}
|
|
67
|
-
.realiiz-form__status{margin-right:auto;font-size:.85rem;color:var(--_muted)}
|
|
68
|
-
.realiiz-form__bar[data-dirty] .realiiz-form__status{color:var(--_fg)}
|
|
69
|
-
.realiiz-form__button{font:inherit;font-weight:600;border-radius:var(--_radius);padding:10px 16px;border:1px solid var(--_border);background:#fff;color:var(--_fg);cursor:pointer;min-height:40px}
|
|
70
|
-
.realiiz-form__button--primary{background:var(--_accent);color:var(--_accent-fg);border-color:var(--_accent)}
|
|
71
|
-
.realiiz-form__button:disabled{opacity:.6;cursor:default}
|
|
72
|
-
.realiiz-md{--_md-head:#fafbfd;--_md-hover:#f4f8fd;--_md-hover-line:#bcd0ea;--_md-on:#eef4fb;--_md-tip:#1f2933;position:relative}
|
|
73
|
-
.realiiz-md__mode{display:inline-flex;align-self:flex-start;width:max-content;gap:2px;padding:3px;background:color-mix(in srgb,var(--_border) 40%,transparent);border-radius:8px;margin-bottom:8px}
|
|
74
|
-
.realiiz-md__mode button{font:inherit;font-size:.8rem;padding:5px 13px;border:0;border-radius:6px;background:transparent;color:var(--_muted);cursor:pointer}
|
|
75
|
-
.realiiz-md__mode button[aria-selected="true"]{background:#fff;color:var(--_fg);box-shadow:0 1px 2px rgba(0,0,0,.12)}
|
|
76
|
-
.realiiz-md__panel{position:relative;z-index:0;display:flex;flex-direction:column;border:1px solid var(--_border);border-radius:10px;background:#fff;overflow:hidden}
|
|
77
|
-
.realiiz-md__panel:focus-within{border-color:var(--_md-hover-line)}
|
|
78
|
-
.realiiz-md__head{position:relative;z-index:5;display:flex;align-items:center;gap:2px;flex-wrap:wrap;padding:5px 7px;background:var(--_md-head);border-bottom:1px solid var(--_border);flex-shrink:0}
|
|
79
|
-
.realiiz-md__tools{display:flex;align-items:center;gap:3px;flex-wrap:wrap}
|
|
80
|
-
.realiiz-md__spacer{flex:1}
|
|
81
|
-
.realiiz-md__head button{position:relative;min-width:31px;height:28px;padding:0 9px;display:inline-flex;align-items:center;justify-content:center;background:#fff;border:1px solid var(--_border);border-radius:6px;font-family:inherit;font-size:.82rem;color:var(--_fg);cursor:pointer;line-height:1}
|
|
82
|
-
.realiiz-md__head button:hover:not(:disabled){border-color:var(--_md-hover-line);background:var(--_md-hover)}
|
|
83
|
-
.realiiz-md__head button:active{background:var(--_md-on)}
|
|
84
|
-
.realiiz-md__head button.on{background:var(--_md-on);border-color:var(--_accent);color:var(--_accent);font-weight:600}
|
|
85
|
-
.realiiz-md__ico{width:15px;height:15px;display:block}
|
|
86
|
-
.realiiz-md__dot{font-size:1.05rem;line-height:1}
|
|
87
|
-
.realiiz-md__sep{width:1px;height:17px;background:var(--_border);margin:0 5px}
|
|
88
|
-
.realiiz-md__insert{display:inline-flex;align-items:center;gap:3px;border-left:1px solid var(--_border);padding-left:8px;margin-left:6px}
|
|
89
|
-
.realiiz-md__insert button{background:#f6f8fa;color:var(--_muted);padding:0;width:31px}
|
|
90
|
-
.realiiz-md__insert button:hover{color:var(--_accent)}
|
|
91
|
-
.realiiz-md__lab{font-size:.74rem;color:var(--_muted);margin-right:3px}
|
|
92
|
-
.realiiz-md__head button[data-tip]::after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;background:var(--_md-tip);color:#fff;font-size:.72rem;padding:4px 8px;border-radius:5px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .12s;z-index:20}
|
|
93
|
-
.realiiz-md__head button[data-tip]:hover::after,.realiiz-md__head button[data-tip]:focus-visible::after{opacity:1}
|
|
94
|
-
.realiiz-md__expand[data-tip]::after{left:auto;right:0}
|
|
95
|
-
.realiiz-md__tgwrap{position:relative;display:inline-flex}
|
|
96
|
-
.realiiz-md__tgrid{position:absolute;top:calc(100% + 6px);left:0;background:#fff;border:1px solid var(--_border);border-radius:9px;padding:9px;box-shadow:0 10px 28px rgba(0,0,0,.14);z-index:7;display:block}
|
|
97
|
-
.realiiz-md__tgcells{display:grid;grid-template-columns:repeat(6,17px);gap:3px}
|
|
98
|
-
.realiiz-md__tgcells i{width:17px;height:15px;border:1px solid var(--_border);border-radius:2px;background:#fff;cursor:pointer;display:block}
|
|
99
|
-
.realiiz-md__tgcells i.hot{background:#dbe9fb;border-color:var(--_accent)}
|
|
100
|
-
.realiiz-md__tglab{display:block;margin-top:8px;font-size:.74rem;color:var(--_muted);text-align:center;white-space:nowrap}
|
|
101
|
-
.realiiz-md .realiiz-md__ta{flex:1 1 auto;border:0;border-radius:0;resize:vertical;background:#fff;max-width:none;padding:16px 18px;line-height:1.65}
|
|
102
|
-
.realiiz-md .realiiz-md__ta:focus{outline:none;box-shadow:none}
|
|
103
|
-
.realiiz-md__preview{padding:20px 24px;background:#fff}
|
|
104
|
-
.realiiz-md__note{padding:4px 2px}
|
|
105
|
-
.realiiz-md--fs{position:fixed;inset:0;z-index:60;background:#fff;padding:14px 22px 22px;overflow:auto;display:flex;flex-direction:column}
|
|
106
|
-
.realiiz-md--fs .realiiz-md__panel{flex:1;min-height:0}
|
|
107
|
-
.realiiz-md--fs .realiiz-md__ta,.realiiz-md--fs .realiiz-md__preview{flex:1;min-height:0;overflow:auto;resize:none}
|
|
108
|
-
.realiiz-prose{max-width:68ch;line-height:1.65}
|
|
109
|
-
.realiiz-chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:40px;padding:5px 8px;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius)}
|
|
110
|
-
.realiiz-chips:focus-within{border-color:var(--_accent);box-shadow:var(--_ring)}
|
|
111
|
-
.realiiz-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 4px 2px 9px;border:1px solid var(--_border);border-radius:999px;font-size:.8rem}
|
|
112
|
-
.realiiz-chip button{font:inherit;line-height:1;width:18px;height:18px;border-radius:50%;border:0;background:transparent;color:var(--_muted);cursor:pointer}
|
|
113
|
-
.realiiz-chips__input{flex:1;min-width:120px;border:0;background:transparent;font:inherit;color:inherit;outline:none;padding:4px}
|
|
114
|
-
.realiiz-chips__count{margin-left:auto;color:var(--_muted);font-size:.75rem}
|
|
115
|
-
.realiiz-gauge{display:inline-flex;align-items:center;gap:10px;font-size:.75rem;color:var(--_muted)}
|
|
116
|
-
.realiiz-gauge__bar{position:relative;width:140px;height:6px;border-radius:3px;background:var(--_border);overflow:hidden}
|
|
117
|
-
.realiiz-gauge__zone{position:absolute;top:0;bottom:0;background:rgba(21,128,61,.28)}
|
|
118
|
-
.realiiz-gauge__fill{position:absolute;top:0;bottom:0;left:0;background:var(--_muted);border-radius:3px;transition:width .12s}
|
|
119
|
-
.realiiz-gauge__text b{font-weight:600;color:inherit}
|
|
120
|
-
.realiiz-gauge--ok{color:#15803d}.realiiz-gauge--ok .realiiz-gauge__fill{background:#15803d}
|
|
121
|
-
.realiiz-gauge--over{color:var(--_danger)}.realiiz-gauge--over .realiiz-gauge__fill{background:var(--_danger)}
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
export { FORM_CSS };
|
|
125
|
-
//# sourceMappingURL=chunk-2GSYBARR.js.map
|
|
126
|
-
//# sourceMappingURL=chunk-2GSYBARR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms-ui/styles.ts"],"names":[],"mappings":";AAMO,IAAM,QAAA,GAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","file":"chunk-2GSYBARR.js","sourcesContent":["/**\n * Theming hooks, same convention as BookingWidget: a root class, BEM elements,\n * and --realiiz-form-* custom properties with fallbacks so the form is usable\n * with zero host CSS and fully themeable with a dozen variables.\n */\n\nexport const FORM_CSS = `\n.realiiz-form{\n --_fg:var(--realiiz-form-fg,#111);\n --_muted:var(--realiiz-form-muted,#666);\n --_border:var(--realiiz-form-border,#cfcfcf);\n --_accent:var(--realiiz-form-accent,#111);\n --_accent-fg:var(--realiiz-form-accent-fg,#fff);\n --_danger:var(--realiiz-form-danger,#b3261e);\n --_radius:var(--realiiz-form-radius,6px);\n --_font:var(--realiiz-form-font,system-ui,-apple-system,\"Segoe UI\",Roboto,sans-serif);\n --_ring:var(--realiiz-form-focus-ring,0 0 0 3px rgba(0,0,0,.15));\n box-sizing:border-box;max-width:100%;color:var(--_fg);font-family:var(--_font);font-size:15px;line-height:1.4;\n}\n.realiiz-form *,.realiiz-form *::before,.realiiz-form *::after{box-sizing:inherit}\n.realiiz-form fieldset{border:0;margin:0 0 20px;padding:0;min-width:0}\n.realiiz-form legend{font-weight:600;font-size:13px;letter-spacing:.02em;text-transform:uppercase;color:var(--_muted);margin-bottom:12px;padding:0}\n.realiiz-form__field{display:block;margin:0 0 16px}\n.realiiz-form__label{display:block;font-weight:500;margin-bottom:6px}\n.realiiz-form__required{color:var(--_danger);margin-left:3px}\n.realiiz-form__control{display:block;width:100%;max-width:100%;font:inherit;color:inherit;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius);padding:9px 11px;min-height:40px}\n.realiiz-form__control:focus{outline:none;border-color:var(--_accent);box-shadow:var(--_ring)}\n.realiiz-form__control--textarea{min-height:110px;resize:vertical}\n.realiiz-form__control--body{min-height:280px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:14px}\n.realiiz-form__control--invalid{border-color:var(--_danger)}\n.realiiz-select{position:relative}\n.realiiz-select__btn{display:flex;align-items:center;justify-content:space-between;gap:10px;text-align:left;cursor:pointer;background:#fff}\n.realiiz-select__btn svg{flex-shrink:0;color:var(--_muted);transition:transform .15s}\n.realiiz-select__btn--open{border-color:var(--_accent);box-shadow:var(--_ring)}\n.realiiz-select__btn--open svg{transform:rotate(180deg)}\n.realiiz-select__btn:disabled{opacity:.6;cursor:default}\n.realiiz-select__placeholder{color:var(--_muted)}\n.realiiz-select__menu{position:absolute;left:0;right:0;top:calc(100% + 6px);margin:0;padding:6px 0;list-style:none;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius);box-shadow:0 8px 24px rgba(14,23,38,.14);max-height:260px;overflow:auto;z-index:40}\n.realiiz-select__item{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:14px;color:var(--_fg);cursor:pointer}\n.realiiz-select__item--active{background:var(--realiiz-form-hover,rgba(0,0,0,.05))}\n.realiiz-select__item--selected{font-weight:600}\n.realiiz-select__check{width:1em;flex-shrink:0;color:var(--_accent);font-weight:700}\n.realiiz-form__check{display:flex;align-items:center;gap:8px;font-weight:500}\n.realiiz-form__check input{width:18px;height:18px;margin:0}\n.realiiz-form__helper{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:var(--_muted);margin-top:4px;min-height:1em}\n.realiiz-form__count{margin-left:auto;font-variant-numeric:tabular-nums}\n.realiiz-form__error{color:var(--_danger);font-size:13px;margin-top:4px}\n.realiiz-image{border:1px dashed var(--_border);border-radius:var(--_radius);padding:16px 18px;background:#fff;outline:none;transition:border-color .15s}\n.realiiz-image--over{border-color:var(--_accent);border-style:solid}\n.realiiz-image--invalid{border-color:var(--_danger)}\n.realiiz-image--busy{opacity:.7}\n.realiiz-image__empty{display:flex;align-items:center;gap:14px;flex-wrap:wrap;color:var(--_muted)}\n.realiiz-image__icon{flex-shrink:0;color:var(--_muted)}\n.realiiz-image__or{font-size:13px}\n.realiiz-image__has{display:flex;align-items:flex-start;gap:16px}\n.realiiz-image__thumb{display:block;max-height:160px;max-width:min(320px,55%);width:auto;object-fit:cover;border-radius:8px;border:1px solid var(--_border);background:#f6f8fa}\n.realiiz-image__meta{display:flex;flex-direction:column;gap:10px;min-width:0}\n.realiiz-image__detail{font-size:13px;color:var(--_muted);word-break:break-all}\n.realiiz-image__actions{display:flex;align-items:center;gap:14px}\n.realiiz-image__remove{font:inherit;font-size:13px;background:none;border:0;padding:0;color:var(--_muted);text-decoration:underline;text-underline-offset:3px;cursor:pointer}\n.realiiz-image__remove:hover{color:var(--_danger)}\n.realiiz-image__hint{font-size:12px;color:var(--_muted);margin-top:10px}\n.realiiz-image .realiiz-form__error{margin-top:8px}\n@media (max-width:720px){.realiiz-image__has{flex-direction:column}.realiiz-image__thumb{max-width:100%}}\n.realiiz-form__alert{border:1px solid var(--_danger);border-radius:var(--_radius);padding:12px 14px;margin:0 0 20px;color:var(--_danger)}\n.realiiz-form__alert ul{margin:6px 0 0;padding-left:18px}\n.realiiz-form__actions{display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;margin-top:8px}\n.realiiz-form__help{text-decoration:underline dotted;text-decoration-color:color-mix(in srgb,currentColor 45%,transparent);text-underline-offset:4px;cursor:help}\n.realiiz-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n.realiiz-form__footer{max-width:920px}\n.realiiz-form__bar{display:flex;align-items:center;gap:10px;margin-top:16px;padding:12px 0;border-top:1px solid var(--_border);background:#fff}\n.realiiz-form__status{margin-right:auto;font-size:.85rem;color:var(--_muted)}\n.realiiz-form__bar[data-dirty] .realiiz-form__status{color:var(--_fg)}\n.realiiz-form__button{font:inherit;font-weight:600;border-radius:var(--_radius);padding:10px 16px;border:1px solid var(--_border);background:#fff;color:var(--_fg);cursor:pointer;min-height:40px}\n.realiiz-form__button--primary{background:var(--_accent);color:var(--_accent-fg);border-color:var(--_accent)}\n.realiiz-form__button:disabled{opacity:.6;cursor:default}\n.realiiz-md{--_md-head:#fafbfd;--_md-hover:#f4f8fd;--_md-hover-line:#bcd0ea;--_md-on:#eef4fb;--_md-tip:#1f2933;position:relative}\n.realiiz-md__mode{display:inline-flex;align-self:flex-start;width:max-content;gap:2px;padding:3px;background:color-mix(in srgb,var(--_border) 40%,transparent);border-radius:8px;margin-bottom:8px}\n.realiiz-md__mode button{font:inherit;font-size:.8rem;padding:5px 13px;border:0;border-radius:6px;background:transparent;color:var(--_muted);cursor:pointer}\n.realiiz-md__mode button[aria-selected=\"true\"]{background:#fff;color:var(--_fg);box-shadow:0 1px 2px rgba(0,0,0,.12)}\n.realiiz-md__panel{position:relative;z-index:0;display:flex;flex-direction:column;border:1px solid var(--_border);border-radius:10px;background:#fff;overflow:hidden}\n.realiiz-md__panel:focus-within{border-color:var(--_md-hover-line)}\n.realiiz-md__head{position:relative;z-index:5;display:flex;align-items:center;gap:2px;flex-wrap:wrap;padding:5px 7px;background:var(--_md-head);border-bottom:1px solid var(--_border);flex-shrink:0}\n.realiiz-md__tools{display:flex;align-items:center;gap:3px;flex-wrap:wrap}\n.realiiz-md__spacer{flex:1}\n.realiiz-md__head button{position:relative;min-width:31px;height:28px;padding:0 9px;display:inline-flex;align-items:center;justify-content:center;background:#fff;border:1px solid var(--_border);border-radius:6px;font-family:inherit;font-size:.82rem;color:var(--_fg);cursor:pointer;line-height:1}\n.realiiz-md__head button:hover:not(:disabled){border-color:var(--_md-hover-line);background:var(--_md-hover)}\n.realiiz-md__head button:active{background:var(--_md-on)}\n.realiiz-md__head button.on{background:var(--_md-on);border-color:var(--_accent);color:var(--_accent);font-weight:600}\n.realiiz-md__ico{width:15px;height:15px;display:block}\n.realiiz-md__dot{font-size:1.05rem;line-height:1}\n.realiiz-md__sep{width:1px;height:17px;background:var(--_border);margin:0 5px}\n.realiiz-md__insert{display:inline-flex;align-items:center;gap:3px;border-left:1px solid var(--_border);padding-left:8px;margin-left:6px}\n.realiiz-md__insert button{background:#f6f8fa;color:var(--_muted);padding:0;width:31px}\n.realiiz-md__insert button:hover{color:var(--_accent)}\n.realiiz-md__lab{font-size:.74rem;color:var(--_muted);margin-right:3px}\n.realiiz-md__head button[data-tip]::after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;background:var(--_md-tip);color:#fff;font-size:.72rem;padding:4px 8px;border-radius:5px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .12s;z-index:20}\n.realiiz-md__head button[data-tip]:hover::after,.realiiz-md__head button[data-tip]:focus-visible::after{opacity:1}\n.realiiz-md__expand[data-tip]::after{left:auto;right:0}\n.realiiz-md__tgwrap{position:relative;display:inline-flex}\n.realiiz-md__tgrid{position:absolute;top:calc(100% + 6px);left:0;background:#fff;border:1px solid var(--_border);border-radius:9px;padding:9px;box-shadow:0 10px 28px rgba(0,0,0,.14);z-index:7;display:block}\n.realiiz-md__tgcells{display:grid;grid-template-columns:repeat(6,17px);gap:3px}\n.realiiz-md__tgcells i{width:17px;height:15px;border:1px solid var(--_border);border-radius:2px;background:#fff;cursor:pointer;display:block}\n.realiiz-md__tgcells i.hot{background:#dbe9fb;border-color:var(--_accent)}\n.realiiz-md__tglab{display:block;margin-top:8px;font-size:.74rem;color:var(--_muted);text-align:center;white-space:nowrap}\n.realiiz-md .realiiz-md__ta{flex:1 1 auto;border:0;border-radius:0;resize:vertical;background:#fff;max-width:none;padding:16px 18px;line-height:1.65}\n.realiiz-md .realiiz-md__ta:focus{outline:none;box-shadow:none}\n.realiiz-md__preview{padding:20px 24px;background:#fff}\n.realiiz-md__note{padding:4px 2px}\n.realiiz-md--fs{position:fixed;inset:0;z-index:60;background:#fff;padding:14px 22px 22px;overflow:auto;display:flex;flex-direction:column}\n.realiiz-md--fs .realiiz-md__panel{flex:1;min-height:0}\n.realiiz-md--fs .realiiz-md__ta,.realiiz-md--fs .realiiz-md__preview{flex:1;min-height:0;overflow:auto;resize:none}\n.realiiz-prose{max-width:68ch;line-height:1.65}\n.realiiz-chips{display:flex;flex-wrap:wrap;gap:6px;align-items:center;min-height:40px;padding:5px 8px;background:#fff;border:1px solid var(--_border);border-radius:var(--_radius)}\n.realiiz-chips:focus-within{border-color:var(--_accent);box-shadow:var(--_ring)}\n.realiiz-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 4px 2px 9px;border:1px solid var(--_border);border-radius:999px;font-size:.8rem}\n.realiiz-chip button{font:inherit;line-height:1;width:18px;height:18px;border-radius:50%;border:0;background:transparent;color:var(--_muted);cursor:pointer}\n.realiiz-chips__input{flex:1;min-width:120px;border:0;background:transparent;font:inherit;color:inherit;outline:none;padding:4px}\n.realiiz-chips__count{margin-left:auto;color:var(--_muted);font-size:.75rem}\n.realiiz-gauge{display:inline-flex;align-items:center;gap:10px;font-size:.75rem;color:var(--_muted)}\n.realiiz-gauge__bar{position:relative;width:140px;height:6px;border-radius:3px;background:var(--_border);overflow:hidden}\n.realiiz-gauge__zone{position:absolute;top:0;bottom:0;background:rgba(21,128,61,.28)}\n.realiiz-gauge__fill{position:absolute;top:0;bottom:0;left:0;background:var(--_muted);border-radius:3px;transition:width .12s}\n.realiiz-gauge__text b{font-weight:600;color:inherit}\n.realiiz-gauge--ok{color:#15803d}.realiiz-gauge--ok .realiiz-gauge__fill{background:#15803d}\n.realiiz-gauge--over{color:var(--_danger)}.realiiz-gauge--over .realiiz-gauge__fill{background:var(--_danger)}\n`;\n"]}
|
package/dist/chunk-JLR5K6RP.js
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
// src/forms/internals.ts
|
|
2
|
-
function asNode(schema, what = "schema") {
|
|
3
|
-
const n = schema;
|
|
4
|
-
if (!n || typeof n !== "object" || !n._zod?.def?.type) {
|
|
5
|
-
throw new TypeError(`walkSchema: ${what} is not a zod 4 schema`);
|
|
6
|
-
}
|
|
7
|
-
return n;
|
|
8
|
-
}
|
|
9
|
-
function checkMessage(def) {
|
|
10
|
-
const e = def.error;
|
|
11
|
-
if (!e) return void 0;
|
|
12
|
-
if (typeof e === "string") return e;
|
|
13
|
-
const out = e({});
|
|
14
|
-
if (typeof out === "string") return out;
|
|
15
|
-
return out?.message;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// src/forms/checks.ts
|
|
19
|
-
function readChecks(node) {
|
|
20
|
-
const constraints = {};
|
|
21
|
-
const messages = {};
|
|
22
|
-
for (const c of node._zod.def.checks ?? []) {
|
|
23
|
-
const d = c._zod.def;
|
|
24
|
-
const msg = checkMessage(d);
|
|
25
|
-
let key;
|
|
26
|
-
switch (d.check) {
|
|
27
|
-
case "min_length":
|
|
28
|
-
constraints.min = d.minimum;
|
|
29
|
-
key = "min_length";
|
|
30
|
-
break;
|
|
31
|
-
case "max_length":
|
|
32
|
-
constraints.max = d.maximum;
|
|
33
|
-
key = "max_length";
|
|
34
|
-
break;
|
|
35
|
-
case "length_equals":
|
|
36
|
-
constraints.exact = d.length;
|
|
37
|
-
key = "length_equals";
|
|
38
|
-
break;
|
|
39
|
-
case "greater_than":
|
|
40
|
-
constraints.min = d.inclusive ? d.value : (d.value ?? 0) + 1;
|
|
41
|
-
key = "greater_than";
|
|
42
|
-
break;
|
|
43
|
-
case "less_than":
|
|
44
|
-
constraints.max = d.inclusive ? d.value : (d.value ?? 0) - 1;
|
|
45
|
-
key = "less_than";
|
|
46
|
-
break;
|
|
47
|
-
case "string_format":
|
|
48
|
-
if (d.format === "regex" && d.pattern) {
|
|
49
|
-
constraints.pattern = d.pattern.source;
|
|
50
|
-
constraints.format = "regex";
|
|
51
|
-
key = "regex";
|
|
52
|
-
} else if (d.format === "url" || d.format === "email") {
|
|
53
|
-
constraints.format = d.format;
|
|
54
|
-
key = d.format;
|
|
55
|
-
} else {
|
|
56
|
-
key = d.format;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case "number_format":
|
|
60
|
-
if (d.format === "safeint" || d.format === "int32") {
|
|
61
|
-
constraints.format = "int";
|
|
62
|
-
key = "int";
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
case "custom":
|
|
66
|
-
key = "custom";
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
key = d.check;
|
|
70
|
-
}
|
|
71
|
-
if (key && msg) messages[key] = msg;
|
|
72
|
-
}
|
|
73
|
-
return { constraints, messages };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/forms/unwrap.ts
|
|
77
|
-
function unwrap(start) {
|
|
78
|
-
let node = start;
|
|
79
|
-
let required = true;
|
|
80
|
-
for (let i = 0; i < 16; i++) {
|
|
81
|
-
const def = node._zod.def;
|
|
82
|
-
if (def.type === "optional" || def.type === "nullable" || def.type === "default") {
|
|
83
|
-
required = false;
|
|
84
|
-
if (!def.innerType) break;
|
|
85
|
-
node = def.innerType;
|
|
86
|
-
} else if (def.type === "pipe") {
|
|
87
|
-
const next = def.out ?? def.in;
|
|
88
|
-
if (!next) break;
|
|
89
|
-
node = next;
|
|
90
|
-
} else {
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return { node, type: node._zod.def.type, required };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/forms/inputs.ts
|
|
98
|
-
var TEXTAREA_MIN_MAX = 120;
|
|
99
|
-
function inputFor(node) {
|
|
100
|
-
const def = node._zod.def;
|
|
101
|
-
const { constraints, messages } = readChecks(node);
|
|
102
|
-
switch (def.type) {
|
|
103
|
-
case "string": {
|
|
104
|
-
if (constraints.format === "url") return { input: "url", constraints, messages };
|
|
105
|
-
const long = (constraints.max ?? 0) > TEXTAREA_MIN_MAX;
|
|
106
|
-
return { input: long ? "textarea" : "text", constraints, messages };
|
|
107
|
-
}
|
|
108
|
-
case "date":
|
|
109
|
-
return { input: "date", constraints, messages };
|
|
110
|
-
case "number":
|
|
111
|
-
case "int":
|
|
112
|
-
return { input: "number", constraints, messages };
|
|
113
|
-
case "boolean":
|
|
114
|
-
return { input: "boolean", constraints, messages };
|
|
115
|
-
case "enum":
|
|
116
|
-
case "literal": {
|
|
117
|
-
const options = Object.values(def.entries ?? {}).map(String);
|
|
118
|
-
return { input: "select", constraints, messages, options };
|
|
119
|
-
}
|
|
120
|
-
case "array": {
|
|
121
|
-
if (def.element) {
|
|
122
|
-
const item = unwrap(def.element);
|
|
123
|
-
const inner = readChecks(item.node);
|
|
124
|
-
constraints.item = inner;
|
|
125
|
-
}
|
|
126
|
-
return { input: "tags", constraints, messages };
|
|
127
|
-
}
|
|
128
|
-
default:
|
|
129
|
-
return { input: "text", constraints, messages };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/forms/labels.ts
|
|
134
|
-
function readMeta(schema) {
|
|
135
|
-
const s = schema;
|
|
136
|
-
const raw = typeof s.meta === "function" ? s.meta() ?? {} : {};
|
|
137
|
-
const pick = (k) => typeof raw[k] === "string" ? raw[k] : void 0;
|
|
138
|
-
const rec = raw.recommended;
|
|
139
|
-
const recommended = Array.isArray(rec) && rec.length === 2 && rec.every((n) => typeof n === "number") ? [rec[0], rec[1]] : void 0;
|
|
140
|
-
const INPUTS = ["text", "textarea", "date", "number", "boolean", "select", "tags", "image", "url", "time"];
|
|
141
|
-
const input = typeof raw.input === "string" && INPUTS.includes(raw.input) ? raw.input : void 0;
|
|
142
|
-
return {
|
|
143
|
-
label: pick("label"),
|
|
144
|
-
placeholder: pick("placeholder"),
|
|
145
|
-
description: pick("description") ?? (typeof s.description === "string" ? s.description : void 0),
|
|
146
|
-
recommended,
|
|
147
|
-
suffix: pick("suffix"),
|
|
148
|
-
help: pick("help"),
|
|
149
|
-
input
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function inputOverrideFor(name, schema, entry) {
|
|
153
|
-
return entry?.inputs?.[name] ?? readMeta(schema).input;
|
|
154
|
-
}
|
|
155
|
-
function recommendedFor(name, schema, entry) {
|
|
156
|
-
return entry?.recommended?.[name] ?? readMeta(schema).recommended;
|
|
157
|
-
}
|
|
158
|
-
function titlecase(name) {
|
|
159
|
-
const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
|
|
160
|
-
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
161
|
-
}
|
|
162
|
-
function labelFor(name, schema, entry) {
|
|
163
|
-
const fromRegistry = entry?.labels?.[name];
|
|
164
|
-
if (fromRegistry) return fromRegistry;
|
|
165
|
-
const meta = readMeta(schema);
|
|
166
|
-
return meta.label ?? meta.description ?? titlecase(name);
|
|
167
|
-
}
|
|
168
|
-
function placeholderFor(name, schema, entry) {
|
|
169
|
-
return entry?.placeholders?.[name] ?? readMeta(schema).placeholder;
|
|
170
|
-
}
|
|
171
|
-
function helpFor(name, schema, entry) {
|
|
172
|
-
return entry?.help?.[name] ?? readMeta(schema).help;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// src/forms/walk.ts
|
|
176
|
-
function walkSchema(schema, entry = {}) {
|
|
177
|
-
const root = asNode(schema);
|
|
178
|
-
const shape = shapeOf(root);
|
|
179
|
-
const names = Object.keys(shape);
|
|
180
|
-
const specs = names.map((name) => {
|
|
181
|
-
const raw = shape[name];
|
|
182
|
-
const { node, required } = unwrap(raw);
|
|
183
|
-
const info = inputFor(node);
|
|
184
|
-
const role = roleFor(name, entry);
|
|
185
|
-
return {
|
|
186
|
-
name,
|
|
187
|
-
label: labelFor(name, raw, entry),
|
|
188
|
-
input: role === "image" ? "image" : inputOverrideFor(name, raw, entry) ?? info.input,
|
|
189
|
-
required,
|
|
190
|
-
constraints: info.constraints,
|
|
191
|
-
messages: info.messages,
|
|
192
|
-
placeholder: placeholderFor(name, raw, entry),
|
|
193
|
-
recommended: recommendedFor(name, raw, entry),
|
|
194
|
-
suffix: readMeta(raw).suffix,
|
|
195
|
-
help: helpFor(name, raw, entry),
|
|
196
|
-
order: 0,
|
|
197
|
-
role,
|
|
198
|
-
options: entry.options?.[name] ?? info.options
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
return applyOrder(specs, entry.order ?? []);
|
|
202
|
-
}
|
|
203
|
-
function shapeOf(root) {
|
|
204
|
-
let node = root;
|
|
205
|
-
for (let i = 0; i < 8 && !node._zod.def.shape; i++) {
|
|
206
|
-
const def = node._zod.def;
|
|
207
|
-
const next = def.innerType ?? def.in;
|
|
208
|
-
if (!next) break;
|
|
209
|
-
node = next;
|
|
210
|
-
}
|
|
211
|
-
const shape = node._zod.def.shape;
|
|
212
|
-
if (!shape) throw new TypeError(`walkSchema: expected an object schema, got "${root._zod.def.type}"`);
|
|
213
|
-
return shape;
|
|
214
|
-
}
|
|
215
|
-
function roleFor(name, entry) {
|
|
216
|
-
if (entry.hidden?.includes(name)) return "hidden";
|
|
217
|
-
if (entry.body === name) return "body";
|
|
218
|
-
if (entry.images?.includes(name)) return "image";
|
|
219
|
-
return "field";
|
|
220
|
-
}
|
|
221
|
-
function applyOrder(specs, order) {
|
|
222
|
-
const rank = new Map(order.map((n, i) => [n, i]));
|
|
223
|
-
const named = specs.filter((s) => rank.has(s.name)).sort((a, b) => rank.get(a.name) - rank.get(b.name));
|
|
224
|
-
const rest = specs.filter((s) => !rank.has(s.name));
|
|
225
|
-
return [...named, ...rest].map((s, i) => ({ ...s, order: i }));
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/forms/registry.ts
|
|
229
|
-
function defineContentType(entry) {
|
|
230
|
-
const where = `defineContentType("${entry.id}")`;
|
|
231
|
-
for (const key of ["id", "label", "folder"]) {
|
|
232
|
-
if (typeof entry[key] !== "string" || entry[key].length === 0) {
|
|
233
|
-
throw new TypeError(`${where}: "${key}" must be a non-empty string`);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
if (typeof entry.filename !== "function") {
|
|
237
|
-
throw new TypeError(`${where}: "filename" must be a function (frontmatter) => string`);
|
|
238
|
-
}
|
|
239
|
-
if (entry.slugFromFilename !== void 0 && typeof entry.slugFromFilename !== "function") {
|
|
240
|
-
throw new TypeError(`${where}: "slugFromFilename" must be a function (fileName) => string | null`);
|
|
241
|
-
}
|
|
242
|
-
if (entry.body !== null && typeof entry.body !== "string") {
|
|
243
|
-
throw new TypeError(`${where}: "body" must be a field name or null`);
|
|
244
|
-
}
|
|
245
|
-
const root = asNode(entry.schema, `${where}: schema`);
|
|
246
|
-
const shape = findShape(root);
|
|
247
|
-
const known = new Set(Object.keys(shape));
|
|
248
|
-
const check = (list, key) => {
|
|
249
|
-
for (const name of list ?? []) {
|
|
250
|
-
if (!known.has(name)) throw new TypeError(`${where}: ${key} names "${name}", which is not a field of the schema`);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
if (entry.body !== null) check([entry.body], "body");
|
|
254
|
-
check(entry.images, "images");
|
|
255
|
-
check(entry.order, "order");
|
|
256
|
-
check(entry.hidden, "hidden");
|
|
257
|
-
check(Object.keys(entry.labels ?? {}), "labels");
|
|
258
|
-
check(Object.keys(entry.placeholders ?? {}), "placeholders");
|
|
259
|
-
check(Object.keys(entry.recommended ?? {}), "recommended");
|
|
260
|
-
check(Object.keys(entry.inputs ?? {}), "inputs");
|
|
261
|
-
check(Object.keys(entry.help ?? {}), "help");
|
|
262
|
-
check(Object.keys(entry.options ?? {}), "options");
|
|
263
|
-
for (const g of entry.groups ?? []) {
|
|
264
|
-
if (typeof g.label !== "string" || g.label.length === 0) throw new TypeError(`${where}: every group needs a label`);
|
|
265
|
-
check(g.fields, `groups["${g.label}"]`);
|
|
266
|
-
}
|
|
267
|
-
return entry;
|
|
268
|
-
}
|
|
269
|
-
function findShape(root) {
|
|
270
|
-
let node = root;
|
|
271
|
-
for (let i = 0; i < 8 && !node._zod.def.shape; i++) {
|
|
272
|
-
const next = node._zod.def.innerType ?? node._zod.def.in;
|
|
273
|
-
if (!next) break;
|
|
274
|
-
node = next;
|
|
275
|
-
}
|
|
276
|
-
if (!node._zod.def.shape) throw new TypeError("defineContentType: schema must be a zod object");
|
|
277
|
-
return node._zod.def.shape;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// src/forms/nav.ts
|
|
281
|
-
function navFromContentTypes(entries, opts = {}) {
|
|
282
|
-
const base = (opts.basePath ?? "/admin").replace(/\/+$/, "");
|
|
283
|
-
const list = Array.isArray(entries) ? entries : Object.values(entries);
|
|
284
|
-
return list.map((e) => ({ id: e.id, label: e.label, href: `${base}/${e.id}`, icon: e.id }));
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export { defineContentType, navFromContentTypes, titlecase, walkSchema };
|
|
288
|
-
//# sourceMappingURL=chunk-JLR5K6RP.js.map
|
|
289
|
-
//# sourceMappingURL=chunk-JLR5K6RP.js.map
|