@ketvietlab/ketsuite 0.1.17 → 0.1.19
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/cli.js +1 -1
- package/dist/modules/backend/design/client/backend-shell.d.mts +2 -2
- package/dist/modules/backend/design/client/backend-shell.d.mts.map +1 -1
- package/dist/modules/backend/design/client/backend-shell.mjs +1 -1
- package/dist/modules/backend/design/client/backend-shell.mjs.map +3 -3
- package/dist/modules/backend/design/content.css +5 -0
- package/dist/scaffold/index.js +1 -1
- package/dist/ui/client/record-modal.d.ts +150 -0
- package/dist/ui/client/record-modal.d.ts.map +1 -0
- package/dist/ui/client/record-modal.js +725 -0
- package/dist/ui/client/record-modal.js.map +1 -0
- package/dist/ui/client/table-selection-view.d.ts.map +1 -1
- package/dist/ui/client/table-selection-view.js +14 -0
- package/dist/ui/client/table-selection-view.js.map +1 -1
- package/dist/ui/hooks.d.ts.map +1 -1
- package/dist/ui/hooks.js +3 -0
- package/dist/ui/hooks.js.map +1 -1
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -0
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/record-modal.d.ts +41 -0
- package/dist/ui/record-modal.d.ts.map +1 -0
- package/dist/ui/record-modal.js +65 -0
- package/dist/ui/record-modal.js.map +1 -0
- package/package.json +4 -4
|
@@ -597,6 +597,11 @@
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
+
/* A record modal island's host holds no content until the island opens it. */
|
|
601
|
+
[data-ui="record-modal-host"] {
|
|
602
|
+
display: none;
|
|
603
|
+
}
|
|
604
|
+
|
|
600
605
|
@media (max-width: 47.9375rem) {
|
|
601
606
|
/* A button sits in a row with the fields it submits, so it is the height of
|
|
602
607
|
one. The 2.75rem touch target this used to take stood half again as tall
|
package/dist/scaffold/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
const VERSION = '0.1.
|
|
3
|
+
const VERSION = '0.1.19';
|
|
4
4
|
const TEMPLATES = new URL('./templates/', import.meta.url);
|
|
5
5
|
const LAYOUT = [
|
|
6
6
|
['package.json.tmpl', 'package.json'],
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { IslandController, JSXChild, TemplateResult } from '@ketvietlab/ketjs-view';
|
|
2
|
+
import { RECORD_PARAM, RECORD_TAB_PARAM, readRecordModalTarget, recordModalClosedHref, recordModalHref } from '../record-modal.tsx';
|
|
3
|
+
export type RecordIssue = {
|
|
4
|
+
field: string | null;
|
|
5
|
+
code: string;
|
|
6
|
+
message: string | null;
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export type RecordCallResult<Value = unknown> = {
|
|
10
|
+
ok: true;
|
|
11
|
+
value: Value;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
issues: RecordIssue[];
|
|
15
|
+
message: string | null;
|
|
16
|
+
status: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Call a server function as the signed-in viewer.
|
|
20
|
+
*
|
|
21
|
+
* A domain refusal (`{ ok: false, errors }` inside the value) and a transport or
|
|
22
|
+
* permission refusal (`ok: false` on the envelope) come back in one shape, so a
|
|
23
|
+
* view never has to know which layer said no.
|
|
24
|
+
*/
|
|
25
|
+
export declare const callRecordFunction: <Value = unknown>(name: string, input: Record<string, unknown>, options?: {
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
idempotencyKey?: string;
|
|
28
|
+
}) => Promise<RecordCallResult<Value>>;
|
|
29
|
+
/** What every record context read must return next to its data. */
|
|
30
|
+
export type RecordContextEnvelope<Data> = {
|
|
31
|
+
data: Data;
|
|
32
|
+
/** Translated strings this record's views use, including `recordModal.*` runtime labels. */
|
|
33
|
+
messages: Record<string, string>;
|
|
34
|
+
};
|
|
35
|
+
export type RecordModalContext<Data> = {
|
|
36
|
+
kind: string;
|
|
37
|
+
id: string;
|
|
38
|
+
tab: string;
|
|
39
|
+
data: Data;
|
|
40
|
+
/** Translate a key the context shipped, interpolating `{name}` params. */
|
|
41
|
+
t: (key: string, params?: Record<string, unknown>) => string;
|
|
42
|
+
/** The refusal for one field of the last submit, translated. */
|
|
43
|
+
fieldError: (name: string) => string | null;
|
|
44
|
+
/** What was typed into a field before a refused submit, or the fallback. */
|
|
45
|
+
draft: (name: string, fallback?: string) => string;
|
|
46
|
+
/** A submit is in flight. */
|
|
47
|
+
busy: boolean;
|
|
48
|
+
dialog: {
|
|
49
|
+
name: string;
|
|
50
|
+
params: Record<string, string>;
|
|
51
|
+
} | null;
|
|
52
|
+
href: (tab: string) => string;
|
|
53
|
+
/** View-local state, set by `data-record-state` controls (click, or change for inputs). */
|
|
54
|
+
state: (key: string, fallback?: string) => string;
|
|
55
|
+
};
|
|
56
|
+
/** Attachments a command uploaded before its function ran, by form field. */
|
|
57
|
+
export type RecordUploads = Record<string, {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string | null;
|
|
60
|
+
}>;
|
|
61
|
+
export type RecordModalCommand<Data> = {
|
|
62
|
+
fn: string;
|
|
63
|
+
/** Map the submitted form to the function's input. */
|
|
64
|
+
input: (form: FormData, context: RecordModalContext<Data>, uploads: RecordUploads) => Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* File fields stored through `/files` before the function runs, each mapped to
|
|
67
|
+
* the attachment's metadata (`resModel`, `resId`, `resField`, `public`). The
|
|
68
|
+
* stored attachment ids reach `input` as its third argument.
|
|
69
|
+
*/
|
|
70
|
+
upload?: Record<string, (form: FormData, context: RecordModalContext<Data>) => Record<string, string>>;
|
|
71
|
+
/**
|
|
72
|
+
* What happens after success. Defaults to `close`. `reload` reads the record
|
|
73
|
+
* again behind a loading state and closes a dialog; `refresh` reads it again in
|
|
74
|
+
* place, keeping the tab, the open dialog and any islands mounted in them.
|
|
75
|
+
*/
|
|
76
|
+
after?: 'close' | 'reload' | 'refresh' | 'stay' | {
|
|
77
|
+
tab: string;
|
|
78
|
+
} | {
|
|
79
|
+
dialog: string | null;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type RecordModalTab<Data> = {
|
|
83
|
+
id: string;
|
|
84
|
+
label: (context: RecordModalContext<Data>) => string;
|
|
85
|
+
visible?: (context: RecordModalContext<Data>) => boolean;
|
|
86
|
+
view: (context: RecordModalContext<Data>) => JSXChild;
|
|
87
|
+
};
|
|
88
|
+
export type RecordModalDialog<Data> = {
|
|
89
|
+
title: (context: RecordModalContext<Data>) => string;
|
|
90
|
+
size?: 'default' | 'large';
|
|
91
|
+
view: (context: RecordModalContext<Data>) => JSXChild;
|
|
92
|
+
};
|
|
93
|
+
export type RecordModalDefinition<Data> = {
|
|
94
|
+
kind: string;
|
|
95
|
+
size?: 'default' | 'large';
|
|
96
|
+
/** A permission-checked read returning `{ data, messages }`. */
|
|
97
|
+
context: {
|
|
98
|
+
fn: string;
|
|
99
|
+
input?: (id: string) => Record<string, unknown>;
|
|
100
|
+
};
|
|
101
|
+
title: (context: RecordModalContext<Data>) => string;
|
|
102
|
+
description?: (context: RecordModalContext<Data>) => string | null;
|
|
103
|
+
header?: (context: RecordModalContext<Data>) => JSXChild;
|
|
104
|
+
tabs?: readonly RecordModalTab<Data>[];
|
|
105
|
+
/** The body of a record without tabs. */
|
|
106
|
+
body?: (context: RecordModalContext<Data>) => JSXChild;
|
|
107
|
+
dialogs?: Record<string, RecordModalDialog<Data>>;
|
|
108
|
+
commands?: Record<string, RecordModalCommand<Data>>;
|
|
109
|
+
/**
|
|
110
|
+
* Runtime labels (`recordModal.*`) in the page's language, available before the
|
|
111
|
+
* record's context has loaded. Without them the loading state has only the
|
|
112
|
+
* built-in English defaults, because `messages` arrive with the context.
|
|
113
|
+
*/
|
|
114
|
+
labels?: Record<string, string> | (() => Record<string, string>);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* English defaults for every label the runtime itself shows. A module passes its
|
|
118
|
+
* own language through `labels`; these only guarantee a reader never sees a key.
|
|
119
|
+
*/
|
|
120
|
+
export declare const RECORD_MODAL_LABELS: Readonly<Record<string, string>>;
|
|
121
|
+
/**
|
|
122
|
+
* The text for a key: the loaded context's messages, then the messages of the
|
|
123
|
+
* last record this modal opened, then the module's labels, then the defaults.
|
|
124
|
+
* Only an unknown key falls through to itself.
|
|
125
|
+
*/
|
|
126
|
+
export declare const resolveRecordModalLabel: (key: string, sources: {
|
|
127
|
+
messages?: Record<string, string> | null;
|
|
128
|
+
previous?: Record<string, string> | null;
|
|
129
|
+
labels?: Record<string, string> | null;
|
|
130
|
+
}) => string;
|
|
131
|
+
/** Field a form (or its submitter) uses to name the command it runs. */
|
|
132
|
+
export declare const RECORD_COMMAND_FIELD = "__command";
|
|
133
|
+
/** Field a link or button uses to open a dialog of the same record. */
|
|
134
|
+
export declare const RECORD_DIALOG_ATTRIBUTE = "data-record-dialog";
|
|
135
|
+
/** Whether anything in a layer was typed into since it rendered. Same rule as route modals. */
|
|
136
|
+
export declare const recordLayerHasDraft: (layer: HTMLElement) => boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Create the island controller for one record kind.
|
|
139
|
+
*
|
|
140
|
+
* The returned factory is what a module exports as its island client:
|
|
141
|
+
* `export const followupModal = createRecordModal(definition)`.
|
|
142
|
+
*/
|
|
143
|
+
export declare const createRecordModal: <Data>(definition: RecordModalDefinition<Data>) => () => IslandController;
|
|
144
|
+
/**
|
|
145
|
+
* Place an island inside a record view. The runtime starts it when the host
|
|
146
|
+
* appears and disposes it when the host leaves; props must be JSON.
|
|
147
|
+
*/
|
|
148
|
+
export declare const recordIsland: (name: string, props: Record<string, unknown>) => TemplateResult;
|
|
149
|
+
export { RECORD_PARAM, RECORD_TAB_PARAM, recordModalHref, recordModalClosedHref, readRecordModalTarget };
|
|
150
|
+
//# sourceMappingURL=record-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-modal.d.ts","sourceRoot":"","sources":["../../../../../../packages/ketsuite/src/ui/client/record-modal.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAExF,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EAErB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAI5B,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,OAAO,IACxC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC1B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAqBhF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAU,KAAK,GAAG,OAAO,QAChD,MAAM,SACL,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACrB;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,KACzD,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CA4BjC,CAAA;AAID,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,CAAC,IAAI,IAAI;IACxC,IAAI,EAAE,IAAI,CAAA;IACV,4FAA4F;IAC5F,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC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