copilotz 1.0.0-rc.52 → 1.0.0-rc.54
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/AGENTS.md +166 -6
- package/CHANGELOG.md +88 -0
- package/README.md +2 -2
- package/hosts/web/mod.d.ts +4 -3
- package/hosts/web/mod.js +4 -3
- package/hosts/web/pt-br/toolkit.js +2 -0
- package/hosts/web/style.d.ts +1 -1
- package/hosts/web/style.js +3 -1
- package/hosts/web/toolkit/anchor.js +33 -7
- package/hosts/web/toolkit/avatar.d.ts +8 -4
- package/hosts/web/toolkit/avatar.js +17 -6
- package/hosts/web/toolkit/calendar.d.ts +6 -0
- package/hosts/web/toolkit/calendar.js +25 -1
- package/hosts/web/toolkit/data-table.d.ts +13 -1
- package/hosts/web/toolkit/data-table.js +19 -6
- package/hosts/web/toolkit/date-picker.d.ts +11 -1
- package/hosts/web/toolkit/date-picker.js +118 -17
- package/hosts/web/toolkit/date-time-picker.d.ts +28 -3
- package/hosts/web/toolkit/date-time-picker.js +30 -13
- package/hosts/web/toolkit/dates.d.ts +24 -11
- package/hosts/web/toolkit/dates.js +109 -19
- package/hosts/web/toolkit/field.d.ts +6 -3
- package/hosts/web/toolkit/field.js +4 -5
- package/hosts/web/toolkit/file-input.d.ts +22 -1
- package/hosts/web/toolkit/file-input.js +41 -13
- package/hosts/web/toolkit/grid.d.ts +1 -1
- package/hosts/web/toolkit/grid.js +2 -2
- package/hosts/web/toolkit/icon.d.ts +5 -0
- package/hosts/web/toolkit/icon.js +5 -0
- package/hosts/web/toolkit/input.d.ts +12 -0
- package/hosts/web/toolkit/input.js +17 -1
- package/hosts/web/toolkit/page.d.ts +8 -1
- package/hosts/web/toolkit/page.js +8 -3
- package/hosts/web/toolkit/picker.d.ts +11 -3
- package/hosts/web/toolkit/picker.js +21 -8
- package/hosts/web/toolkit/rows-editor.d.ts +11 -2
- package/hosts/web/toolkit/rows-editor.js +10 -4
- package/hosts/web/toolkit/screen.d.ts +20 -0
- package/hosts/web/toolkit/screen.js +15 -0
- package/hosts/web/toolkit/select.d.ts +9 -1
- package/hosts/web/toolkit/select.js +7 -2
- package/hosts/web/toolkit/toolbar.d.ts +6 -4
- package/hosts/web/toolkit/toolbar.js +3 -2
- package/hosts/web/toolkit/words.d.ts +1 -1
- package/hosts/web/toolkit/words.js +2 -0
- package/package.json +2 -2
- package/plugins/access/email/actions/send.js +8 -2
- package/plugins/access/email/adapters/console.js +1 -1
- package/plugins/access/email/adapters/resend.js +2 -0
- package/plugins/access/email/adapters/sendmail.d.ts +13 -0
- package/plugins/access/email/adapters/sendmail.js +59 -0
- package/plugins/access/email/contract.d.ts +24 -1
- package/plugins/access/email/mod.d.ts +5 -2
- package/plugins/access/email/mod.js +10 -3
- package/plugins/access/email/shared/mime.d.ts +5 -1
- package/plugins/access/email/shared/mime.js +34 -8
- package/plugins/billing/usage/views/web/words.d.ts +1 -1
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/program/workloads/search.d.ts +1 -1
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/testing/mod.js +1 -1
package/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@ A guide for coding agents (Claude Code, Codex, Cursor, Gemini) building an app w
|
|
|
4
4
|
it whole before you write code. The last section is for work on Copilotz itself.
|
|
5
5
|
|
|
6
6
|
It ships in the package (`node_modules/copilotz/AGENTS.md`, and `@copilotz/copilotz` on JSR) and
|
|
7
|
-
goes with `copilotz@1.0.0-rc.
|
|
7
|
+
goes with `copilotz@1.0.0-rc.54`. Every docs page is Markdown at
|
|
8
8
|
`https://copilotz.com/docs/<slug>.md`, and https://copilotz.com/llms.txt lists them all. When you're
|
|
9
9
|
unsure of a name, fetch its page or read the package's types (`node_modules/copilotz/**/*.d.ts`).
|
|
10
10
|
Don't guess.
|
|
@@ -64,12 +64,12 @@ There's no project generator. Set a project up as the docs' courses do, on Node
|
|
|
64
64
|
```sh
|
|
65
65
|
mkdir my-app && cd my-app
|
|
66
66
|
npm init -y && npm pkg set type=module
|
|
67
|
-
npm install copilotz@1.0.0-rc.
|
|
67
|
+
npm install copilotz@1.0.0-rc.54 react@19 react-dom@19
|
|
68
68
|
npm install -D typescript @types/node @types/react @types/react-dom esbuild
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Pin the version: npm's `latest` tag still points at an early release candidate. On Deno, run
|
|
72
|
-
`deno add jsr:@copilotz/copilotz` and map `"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
72
|
+
`deno add jsr:@copilotz/copilotz` and map `"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.54"` in
|
|
73
73
|
`deno.json`, so imports read the same.
|
|
74
74
|
|
|
75
75
|
Node runs `.ts` files as they are, so there's no build step. It doesn't run `.tsx`: tests that load
|
|
@@ -95,8 +95,10 @@ plugins/<name>/
|
|
|
95
95
|
actions.ts … one file per primitive; or collections/, actions/, views/… with one file per
|
|
96
96
|
declaration, as Copilotz's own plugins are laid out
|
|
97
97
|
contract.ts what other plugins may import: shapes and small helpers, never code
|
|
98
|
-
web.tsx its web
|
|
98
|
+
web.tsx names its web Views, and nothing else; terminal.ts, its terminal front end
|
|
99
|
+
web/ one View per file (screen:…, dialog:…, panel:…), the components they draw beside
|
|
99
100
|
server.ts the web host: reads the environment, passes settings to plugins()
|
|
101
|
+
front.ts the browser's plugins, in order; browser.tsx, the page's code: web({ plugins })
|
|
100
102
|
tests/kit.ts the app as app.ts makes it, in memory, with a scripted model
|
|
101
103
|
tests/*.test.ts
|
|
102
104
|
.env OPENAI_API_KEY=… (optional; dev and terminal read it: --env-file-if-exists=.env)
|
|
@@ -108,7 +110,7 @@ line `@AGENTS.md` (Claude Code reads `CLAUDE.md`, and follows the import). Keep
|
|
|
108
110
|
```markdown
|
|
109
111
|
# AGENTS.md
|
|
110
112
|
|
|
111
|
-
This app runs on Copilotz (copilotz@1.0.0-rc.
|
|
113
|
+
This app runs on Copilotz (copilotz@1.0.0-rc.54). Read node_modules/copilotz/AGENTS.md first;
|
|
112
114
|
https://copilotz.com/llms.txt lists the docs, as Markdown.
|
|
113
115
|
|
|
114
116
|
- `npm test` runs every test offline, with a scripted model: run it after each change.
|
|
@@ -306,7 +308,8 @@ Test what callers may not do as well: call as someone else, and `assert.rejects`
|
|
|
306
308
|
- **Settings are resources, not code.** `app.ts` reads no environment: the server, the terminal or a
|
|
307
309
|
test passes settings in. Agents name a model alias that the app sets.
|
|
308
310
|
- **Writes that must agree go in one `ctx.transaction`.** A refused write rolls it all back. It
|
|
309
|
-
holds the store's writer, so keep slow work out.
|
|
311
|
+
holds the store's writer, so keep slow work out. Another plugin's Action joins it with `tx.call`
|
|
312
|
+
when that Action is `atomic: true`.
|
|
310
313
|
- **Who acts:** `personOf(ctx.actor)`, not `ctx.actor.id` (an agent's is its own). Where: `ctx.in`.
|
|
311
314
|
A tool works where its chat is.
|
|
312
315
|
- **Going past the actor's reach is a named grant,** `ctx.as(grant("…"))`, in trusted code, on the
|
|
@@ -326,6 +329,163 @@ Test what callers may not do as well: call as someone else, and `assert.rejects`
|
|
|
326
329
|
- **Online:** `devSignIn` is for this machine only; Copilotz won't start it with a public origin.
|
|
327
330
|
Keep the `links` secret (32 bytes or more) across restarts, or MCP conversations start over.
|
|
328
331
|
|
|
332
|
+
## A business app's web front end
|
|
333
|
+
|
|
334
|
+
Screens for people at work: lists, forms in dialogs, dates, a home, printed documents.
|
|
335
|
+
[A business app's screens](https://copilotz.com/docs/guides/a-business-apps-screens.md) builds each
|
|
336
|
+
one in full, as files that compile;
|
|
337
|
+
[the web toolkit](https://copilotz.com/docs/guides/the-web-toolkit.md) has every piece, prop and
|
|
338
|
+
token. Read both before the first screen.
|
|
339
|
+
|
|
340
|
+
**Files and names.**
|
|
341
|
+
|
|
342
|
+
- **One View per file**, in `plugins/<name>/web/`, with the React components it draws beside it.
|
|
343
|
+
`web.tsx` only names the plugin's Views, as `mod.ts` assembles the server side. Not one big
|
|
344
|
+
`web.tsx`, and no shared UI library of the app's own.
|
|
345
|
+
- **A name says where a View shows.** `screen:<place>` is a whole screen at `/<place>…`.
|
|
346
|
+
`dialog:<name>` is a dialog over a screen, at an address of that screen (`/customers/12`), so Back
|
|
347
|
+
closes it and the list behind keeps its page. `panel:<name>` is a part of another View that reads
|
|
348
|
+
its own data.
|
|
349
|
+
- **The app's frame** is a View named `web.shell`, the one the web host observes for the address:
|
|
350
|
+
given `{ path, query }`, it draws the bars and shows ``ctx.show(`screen:${place}`, where)``. List
|
|
351
|
+
its plugin last among the browser's. Under Copilotz's own shell (`webShell`), `/<kind>/<id>` shows
|
|
352
|
+
the View named `<kind>` or `web.<kind>` instead.
|
|
353
|
+
|
|
354
|
+
**Views read, handlers call Actions.**
|
|
355
|
+
|
|
356
|
+
- **A View reads in its own body** with `ctx.db`: a named query, `.query(name, params)`, or `find`,
|
|
357
|
+
`findOne`, `countDocuments`. A read is `{ status: "loading" }`, then `{ status: "ready", value }`,
|
|
358
|
+
and the View runs again when a commit changes it. It hands values to React components. Don't fetch
|
|
359
|
+
in an effect, poll, or call `/api/` from the page.
|
|
360
|
+
- **Screens read named queries with an `allow`** (`people`): they run on the server, as whoever
|
|
361
|
+
asks. In the browser a View's own `find` reaches only a collection a rule speaks for (`shared`, or
|
|
362
|
+
a `guard`); any other answers `forbidden` ("You can't see this here").
|
|
363
|
+
- **Handlers call Actions** with `ctx.call(name, input)`: a click, a submit. A View never writes,
|
|
364
|
+
and calls nothing while it renders. Suggestions as someone types come from an unrecorded Action
|
|
365
|
+
(`record: false`, with an `allow`) that runs the query.
|
|
366
|
+
- **A View is a function the runtime runs again, not a component:** no hooks, no state. A form's
|
|
367
|
+
draft, a chosen file and `useShortcuts` live in a component the View returns.
|
|
368
|
+
- **`ctx.show(name, item)` goes in a View's body only.** It's how a View shows a View: what it
|
|
369
|
+
returns is a part that reads and redraws on its own, handed to a component as a child or a prop.
|
|
370
|
+
Another plugin's View is shown by name, without importing its code (`undefined` when there's
|
|
371
|
+
none). Called later (a component's render, a handler, a table's `render` or `detail`), it throws:
|
|
372
|
+
`<LazyView kind="panel:…" item={…} />` shows a View on demand.
|
|
373
|
+
- **Validation errors come from the Action.** The browser's `required` and `type` help first. Then
|
|
374
|
+
the Action checks, for every caller, and throws
|
|
375
|
+
`failure("invalid", "Give the name.", { public:
|
|
376
|
+
true })`: `ctx.call` rejects with those words,
|
|
377
|
+
and a `Form` whose `onSubmit` throws shows them at its top. A refusal about one field names it in
|
|
378
|
+
`detail` (`Object.assign(failure(…), { detail: {
|
|
379
|
+
field: "name" } })`), and the form puts it in
|
|
380
|
+
that `Field`'s `error`. An `input` schema's messages are for developers. A dialog closes only
|
|
381
|
+
after the Action answered.
|
|
382
|
+
|
|
383
|
+
**Toolkit first.**
|
|
384
|
+
|
|
385
|
+
- **Every screen is the toolkit's pieces**, `copilotz/web`, layout included. The look is the theme's
|
|
386
|
+
configuration and nothing else: the `theme` resource's colours (`light`, `dark`), sizes (`tokens`)
|
|
387
|
+
and each piece's own tokens (`button-height`, `table-stripe`…). No stylesheet, no `style={{…}}`
|
|
388
|
+
for a look, no rule on a `.copilotz-*` class, no restyled copy of a piece. `className` may name an
|
|
389
|
+
element for a test, never restyle it.
|
|
390
|
+
- **Something the toolkit lacks is a gap to report**, with the smallest example of what's needed,
|
|
391
|
+
never a reason for CSS. Compose first: most "missing" pieces are a `Grid`, a `Stack` or a `Card`
|
|
392
|
+
of existing ones.
|
|
393
|
+
- **The one exception is a printed document's paper layout**: `@media print` rules beside it.
|
|
394
|
+
- **Words and formats are the app's.** The toolkit's words (`toolkit.noRows`, the date presets) are
|
|
395
|
+
changed by key in the `words` resource
|
|
396
|
+
([WORDS.md](https://github.com/copilotzhq/copilotz/blob/main/hosts/web/WORDS.md) lists them). Time
|
|
397
|
+
zone and date patterns are settings the screens read, never the browser's locale.
|
|
398
|
+
- **Where the names are:** the toolkit guide's sections and its "Every piece's tokens" tables; the
|
|
399
|
+
types, `node_modules/copilotz/hosts/web/toolkit/*.d.ts`, and the theme's,
|
|
400
|
+
`node_modules/copilotz/hosts/web/theme/default.d.ts`.
|
|
401
|
+
|
|
402
|
+
The pieces, by job:
|
|
403
|
+
|
|
404
|
+
- **Layout:** `Page`, `Screen`, `Stack`, `Grid`, `GridItem`, `Toolbar`, `Split`, `Card`,
|
|
405
|
+
`ListGroup`, `Tabs`, `Divider`, `Spacer`, `Heading`, `Text`.
|
|
406
|
+
- **Fields:** `Form`, `Field`, `Input`, `Textarea`, `Select`, `Checkbox`, `Radio`, `Switch`,
|
|
407
|
+
`Picker`, `MultiPicker`, `Autocomplete`, `TagsInput`, `FileInput`, `RowsEditor`, `DatePicker`,
|
|
408
|
+
`DateRangePicker`, `DateTimePicker`, `TimeFields`.
|
|
409
|
+
- **Actions and overlays:** `Button`, `IconButton`, `Menu`, `Popover`, `Dialog`, `Drawer`,
|
|
410
|
+
`Tooltip`, `toast` and `Toasts`.
|
|
411
|
+
- **Data:** `DataTable` (with `tableAddress`, `tableQuery`), `Pagination`, `DetailList`, `Badge`,
|
|
412
|
+
`Chip`, `Avatar`, `Notice`, `EmptyState`, `Skeleton`, `Spinner`, `Kbd`.
|
|
413
|
+
- **An app's own frame:** `AppBar`, `TopBar`, `TileGrid`, `LiveClock`, `Logo`, `Icon` (`drawing`: an
|
|
414
|
+
app's own glyph).
|
|
415
|
+
- **Paper and files:** `NoPrint`, `PrintOnly`, `Barcode`, `download`, `exportFile`; on a server,
|
|
416
|
+
`documentPdf` from `copilotz/web/export`. **Keys:** `useShortcuts`, `shortcutLabel`.
|
|
417
|
+
|
|
418
|
+
**Short recipes** (whole, in the guide):
|
|
419
|
+
|
|
420
|
+
- **A list with search, filters, paging and exports:** a `Page` (`width="lg"`, New in `actions`)
|
|
421
|
+
over a `Toolbar` of filters and a `DataTable`. Up to a few thousand rows, give the table every row
|
|
422
|
+
and it searches, sorts, pages and exports them (`exportAll`: every matching row). More, a named
|
|
423
|
+
query takes the table's state and answers `{ rows, total }`: spread `tableAddress(where, 25)` on
|
|
424
|
+
the table, give it `total`, and keep each filter in the address too, back to the first page
|
|
425
|
+
(`go(path + tableQuery(where, { ...state, offset: 0 }, { from, to }))`). The export menu saves the
|
|
426
|
+
rows shown; every row of a server-paged list is an unrecorded Action's, saved with `download`.
|
|
427
|
+
- **A create or edit form in a dialog:** the screen shows
|
|
428
|
+
`ctx.show("dialog:customer", { _id, back
|
|
429
|
+
})` when its address names one (`/customers/new`,
|
|
430
|
+
`/customers/<id>`). The dialog's View reads the record and returns a component: a `Dialog`
|
|
431
|
+
(`placement="top"`) around a `Form` of `Field
|
|
432
|
+
layout="row"`s, Save in its footer submitting the
|
|
433
|
+
form by its id (`form="customer"`). `onSubmit` calls the Action, then `toast()` and `go(back)`.
|
|
434
|
+
- **Date, date-time and date-range fields:** days are `YYYY-MM-DD` and times `YYYY-MM-DD HH:mm` or
|
|
435
|
+
`HH:mm:ss`, the app's clock time with no zone, never ISO timestamps. `todayIn(timeZone)` and
|
|
436
|
+
`nowIn(timeZone)` in the app's zone, `format` patterns from its settings. `DatePicker`;
|
|
437
|
+
`DateTimePicker` keeps a value's seconds until its time changes (`seconds` shows them);
|
|
438
|
+
`DateRangePicker` has `presets` (or `rangePresets(…)`), typed From and To, and `time` for ends
|
|
439
|
+
with a time of day.
|
|
440
|
+
- **A sign-in page:** Copilotz's own, with `passwordSignIn` (staff with usernames) or `emailSignIn`:
|
|
441
|
+
the theme gives its look (`themeOf([look])` on the server), the `signInPage` resource its words
|
|
442
|
+
and pitch. Accounts come from an Action of the app's that calls `password.set`. Don't write a
|
|
443
|
+
sign-in route or a session cookie. A page before sign-in is `routePage` (`copilotz/web/server`)
|
|
444
|
+
with a `Screen`, which centres a card and keeps a footer at the window's foot.
|
|
445
|
+
- **A home of tiles with an app bar:** the frame's `web.shell`: a `TopBar` (`LiveClock`, who's
|
|
446
|
+
signed in, Sign out with `signOut()`), an `AppBar` (`items`, `active`), the screen, and
|
|
447
|
+
`<Toasts />` once. At `/`, a `Page` of a `TileGrid`.
|
|
448
|
+
- **A printed document:** a screen at its own address: a `Page` with Print in a `NoPrint`, its
|
|
449
|
+
content (`DetailList`, `DataTable`, `Barcode`), `PrintOnly` for paper's words, and the paper's
|
|
450
|
+
`@media print` rules beside it. It prints without the bars, buttons or the page's header
|
|
451
|
+
(`printHeader` keeps it). The same as a PDF on a server, for e-mail: `documentPdf`.
|
|
452
|
+
- **Keyboard shortcuts:** `useShortcuts({ "Alt+N": add, Escape: { run: close, inFields: true } })`
|
|
453
|
+
in a component of the screen, and `<Kbd>{shortcutLabel("Alt+N")}</Kbd>` where it's offered. Keys
|
|
454
|
+
wait while someone types in a field or a dialog is open. No `keydown` listener on `document`.
|
|
455
|
+
- **File and image inputs:** `FileInput` (`accept`; `chooseLabel`, `changeLabel`, `removeLabel`;
|
|
456
|
+
`current` and `onRemove` for a stored file). A picture chosen shows in an `Avatar`
|
|
457
|
+
(`picture={URL.createObjectURL(file)}`, `initial={false}`). The form sends it to an Action as a
|
|
458
|
+
`data:` address, the Action `private: ["picture"]` so its record doesn't keep it twice; big files
|
|
459
|
+
are served by a route with `runtime.bytes`.
|
|
460
|
+
|
|
461
|
+
**Common mistakes:**
|
|
462
|
+
|
|
463
|
+
- A UI kit and stylesheets of the app's own, inline styles for looks, or overrides of `.copilotz-*`,
|
|
464
|
+
instead of the toolkit and the theme. Hand-made `<table>`s of fields (use `DataTable` with fields
|
|
465
|
+
in cells, or `RowsEditor`), a hidden `<input type="file">` behind buttons (`FileInput`), the
|
|
466
|
+
browser's `datetime-local` (`DateTimePicker`), a `document` key listener (`useShortcuts`), a form
|
|
467
|
+
part listening for the DOM's `submit` (`Form` and `useFormSubmit`).
|
|
468
|
+
- One big `web.tsx`; a View that holds state or hooks; a screen fetching `/api/queries/…` from an
|
|
469
|
+
effect instead of reading `ctx.db` in the View; a browser View's `find` on a collection no rule
|
|
470
|
+
speaks for, instead of a named query; `ctx.show` in a row's `render`.
|
|
471
|
+
- A refusal returned as a value (`{ ok: false }`) instead of a thrown public `failure`: the REST API
|
|
472
|
+
answers 200 and a script believes it worked. A second Action, or a second input shape, for
|
|
473
|
+
scripts.
|
|
474
|
+
- A table's page, sort and filters kept in component state: Back and a closed dialog lose them. Keep
|
|
475
|
+
them in the address.
|
|
476
|
+
- Forms as pages, a capability reachable only by an Action no screen calls, a disabled placeholder
|
|
477
|
+
for a field that should work. Open every screen in a browser and use it, not only its tests.
|
|
478
|
+
- A save per field on blur, racing the next one: keep a record's edits together and send them once
|
|
479
|
+
(Save, or a row's Update and Enter).
|
|
480
|
+
- Dates in the browser's locale (`toLocaleString`, `<input type="date">`) or as ISO timestamps given
|
|
481
|
+
to a picker; a function `format` on a range people type into (it can't be read back: use a
|
|
482
|
+
pattern); a record's date-time saved unchanged without its seconds.
|
|
483
|
+
- A `controlWidth` from rc.52–53 or from a CSS-grid habit. Both `labelWidth` and `controlWidth` are
|
|
484
|
+
shares of the whole row: `"33.33%"` and `"66.67%"` fill it.
|
|
485
|
+
- A workaround copied from an older release: rc.54 has `Screen`, typed range ends, seconds, `hidden`
|
|
486
|
+
on layout pieces, fields that fit table cells, `detailOpen`, `Toolbar grow`, a file field's own
|
|
487
|
+
words and picture previews.
|
|
488
|
+
|
|
329
489
|
## Recipes
|
|
330
490
|
|
|
331
491
|
Each link is a page as Markdown. GS is Getting Started (a salon's bookings, 10 chapters). BC is
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
+
## 1.0.0-rc.54 — 2026-11-17
|
|
2
|
+
|
|
3
|
+
What a business app's screens still asked of the toolkit and of e-mail, and the docs that show a
|
|
4
|
+
coding agent how to build them.
|
|
5
|
+
|
|
6
|
+
**Changed:**
|
|
7
|
+
|
|
8
|
+
- **`Field`'s `controlWidth` is a share of the whole row** (label and control), as a grid column is,
|
|
9
|
+
no longer of the control's column: `labelWidth="33.33%"` with `controlWidth="66.67%"` fills the
|
|
10
|
+
row. Its token `field-row-control-width` is `1fr` by default.
|
|
11
|
+
- **A `Page`'s header doesn't print**, as the toolkit's bars don't; `printHeader` keeps it.
|
|
12
|
+
|
|
13
|
+
**Dates:**
|
|
14
|
+
|
|
15
|
+
- **`DateRangePicker`** has typed From and To fields over its months, in the field's `format`: a
|
|
16
|
+
date moves the range and the months, anything else is marked and changes nothing. A long range
|
|
17
|
+
opens on its start's months. `time` gives each end a time of day. Apply and Cancel stay in view
|
|
18
|
+
when the panel scrolls.
|
|
19
|
+
- **`DateTimePicker`** and the day-time helpers take `YYYY-MM-DD HH:mm:ss`: a value's seconds are
|
|
20
|
+
kept until its time is changed (a form saving a record's date unchanged dropped them), and
|
|
21
|
+
`seconds` shows them in a field of their own.
|
|
22
|
+
- **A popover with no room over or under its field** (a range's panel low in a short window) goes on
|
|
23
|
+
the roomier side, as tall as that room, and scrolls inside: it no longer runs past the window's
|
|
24
|
+
foot, so the range's Apply and Cancel stay in view.
|
|
25
|
+
- **New exports:** `TimeFields` (a time of day's fields alone, the pickers' own; its value a
|
|
26
|
+
`Clock`, `{ hour, minute, second? }`), `parseDay` (a day read back in a picker's `format`),
|
|
27
|
+
`parsePattern` (a day read back by a pattern) and `partsOfDayTime`.
|
|
28
|
+
|
|
29
|
+
**Tables and fields:**
|
|
30
|
+
|
|
31
|
+
- **Fields in `DataTable` cells** fill their column and shrink with it, `Select` and the pickers
|
|
32
|
+
without their minimum width there; `layout="fixed"` keeps columns at their `width`s.
|
|
33
|
+
- **`detailOpen`** opens a table's detail rows: all of them (`true`, with no button) or those a
|
|
34
|
+
function picks.
|
|
35
|
+
- **A wide table no longer widens the page**: its screen-reader header words stay inside its scroll.
|
|
36
|
+
- **`Select`, `Picker` and `MultiPicker` take `addon` and `addonEnd`**, as `Input` does.
|
|
37
|
+
- **`FileInput`** takes its own words (`chooseLabel`, `changeLabel`, `removeLabel`) and a file
|
|
38
|
+
already stored (`current`, removed by `onRemove`).
|
|
39
|
+
- **`FileInput` wraps in a narrow column** (a phone, a table's cell): the name takes a line of its
|
|
40
|
+
own, cut short, and its buttons' words wrap, so Remove no longer runs past the field.
|
|
41
|
+
- **`RowsEditor`**: `add={false}` leaves out its add buttons; `removeIcon` and `removeLabel` set the
|
|
42
|
+
remove button.
|
|
43
|
+
- **`Avatar`** shows a picture picked but not yet sent (`blob:`, image `data:`), and
|
|
44
|
+
`initial={false}` draws an empty box.
|
|
45
|
+
|
|
46
|
+
**Layout:**
|
|
47
|
+
|
|
48
|
+
- **`hidden` hides any toolkit piece**: a `Stack`'s or `Grid`'s own display no longer wins over it.
|
|
49
|
+
- **`Screen`**: a frame that fills the window, centring what it holds and keeping a `footer` at the
|
|
50
|
+
window's foot: a sign-in's card, a route's own page.
|
|
51
|
+
- **`Page` `align="center"`** centres the title and description; **`Toolbar` `grow`** takes the room
|
|
52
|
+
left (a search field).
|
|
53
|
+
- **Icons:** `cart`, `gift`, `credit-card`, `piggy-bank`, `tags`.
|
|
54
|
+
|
|
55
|
+
**E-mail:**
|
|
56
|
+
|
|
57
|
+
- **The `sendmail` adapter** hands a message to a sendmail program (Postfix's, Exim's, msmtp's):
|
|
58
|
+
`adapter: "sendmail"`, `sendmail: { path, args, timeout }`. It runs the program with arguments,
|
|
59
|
+
never a shell, recipients after `--`. The e-mail plugin exports its MIME writer (`mime`) for an
|
|
60
|
+
app's own adapter, and the writer refuses a line break in a header.
|
|
61
|
+
- **Inline images:** an attachment with an `id` is inline, and the HTML shows it as `cid:<id>` (a
|
|
62
|
+
receipt's logo, without a data address counting against the HTML's 500,000 characters). SMTP,
|
|
63
|
+
sendmail and Resend send them.
|
|
64
|
+
|
|
65
|
+
**Docs:**
|
|
66
|
+
|
|
67
|
+
- **AGENTS.md has a business app's web front end:** the files (`plugins/<name>/web/`, one View per
|
|
68
|
+
file, `web.tsx` only naming them), the names (`screen:`, `dialog:`, `panel:`), an app's own frame
|
|
69
|
+
(`web.shell`), Views that read with `ctx.db` and handlers that call Actions, `ctx.show` in a
|
|
70
|
+
View's body, where a form's errors come from, the toolkit first with no CSS, its pieces by job,
|
|
71
|
+
short recipes, and the common mistakes.
|
|
72
|
+
- **[A business app's screens](docs/guides/a-business-apps-screens.md)**, a new guide: the recipes
|
|
73
|
+
in full, as files that compile: an app's frame and home of tiles, a list with search, filters,
|
|
74
|
+
paging and exports, a form in a dialog, a View inside a View, dates, sign-in, a printed document,
|
|
75
|
+
keyboard shortcuts, files and pictures.
|
|
76
|
+
- **[The web toolkit](docs/guides/the-web-toolkit.md)** for rc.54: `Screen` for a sign-in or a
|
|
77
|
+
route's own page; `Field`'s widths as shares of the whole row, and how to convert one from rc.53;
|
|
78
|
+
the range's typed From and To, and why a typed range wants a pattern `format` (a function can't be
|
|
79
|
+
read back); ends with times, a preset's `00:00` to `23:59`; seconds in day-times; `TimeFields` and
|
|
80
|
+
the day-time helpers.
|
|
81
|
+
|
|
82
|
+
## 1.0.0-rc.53 — 2026-11-16
|
|
83
|
+
|
|
84
|
+
**A page on `*.localhost` connects.** A page served on a `*.localhost` host (`shop.localhost`) now
|
|
85
|
+
connects: Oxian 0.23.7 lets its socket use `ws://` to any `*.localhost` host, which browsers keep on
|
|
86
|
+
the machine (RFC 6761). Before, such a page loaded and stayed blank. rc.50 already let `devSignIn`
|
|
87
|
+
answer there.
|
|
88
|
+
|
|
1
89
|
## 1.0.0-rc.52 — 2026-11-16
|
|
2
90
|
|
|
3
91
|
The web toolkit becomes a whole app's: what rebuilding a point of sale on Copilotz asked of it, in
|
package/README.md
CHANGED
|
@@ -152,7 +152,7 @@ ana sees: Tue 10:00, Wed 15:00
|
|
|
152
152
|
```sh
|
|
153
153
|
npm install copilotz@next # Node 24+ (npm, pnpm, yarn)
|
|
154
154
|
bun add copilotz@next # Bun
|
|
155
|
-
deno add jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
155
|
+
deno add jsr:@copilotz/copilotz@^1.0.0-rc.54 # Deno 2.9+ (or `deno add npm:copilotz@next`)
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
Until 1.0, the release candidates are on npm's `next` tag, and a plain `npm install copilotz` or
|
|
@@ -166,7 +166,7 @@ OPENAI_API_KEY=sk-… node salon.ts # or bun salon.ts, or deno run -A salon.t
|
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
On Deno, map the name `copilotz` in `deno.json`
|
|
169
|
-
(`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
169
|
+
(`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.54"`) so the imports read the same everywhere.
|
|
170
170
|
Copilotz runs on Node 24+, Deno 2.9+ and Bun, and it's built on web standards for Cloudflare Workers
|
|
171
171
|
and the browser.
|
|
172
172
|
|
package/hosts/web/mod.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export { type Space } from "./toolkit/space.js";
|
|
|
56
56
|
export { type Align, Divider, type Justify, Spacer, Stack } from "./toolkit/stack.js";
|
|
57
57
|
export { Grid, GridItem } from "./toolkit/grid.js";
|
|
58
58
|
export { Toolbar } from "./toolkit/toolbar.js";
|
|
59
|
+
export { Screen } from "./toolkit/screen.js";
|
|
59
60
|
export { Split } from "./toolkit/split.js";
|
|
60
61
|
export { ListGroup, type ListGroupItem } from "./toolkit/list-group.js";
|
|
61
62
|
export { Heading, Text, type TextTone } from "./toolkit/text.js";
|
|
@@ -67,10 +68,10 @@ export { type Column, type Key as RowKey, PAGE_SIZES, type TableState, tableView
|
|
|
67
68
|
export { tableAddress, tableQuery, tableState } from "./table-address.js";
|
|
68
69
|
export { download, EXPORT_FORMATS, exportFile, type ExportFormat, type ExportOptions, type Sheet, toCsv, toExcel, toJson, toPdf, toSql, toXlsx, toXml, } from "./toolkit/export.js";
|
|
69
70
|
export { documentPdf, type Drawn, type PageSize, type PdfFont, type PdfOptions, tablePdf, textWidth, wrapText, } from "./toolkit/pdf.js";
|
|
70
|
-
export { Calendar, type CalendarValue, type DayFormat, formatDay } from "./toolkit/calendar.js";
|
|
71
|
+
export { Calendar, type CalendarValue, type DayFormat, formatDay, parseDay, } from "./toolkit/calendar.js";
|
|
71
72
|
export { DatePicker, DateRangePicker, type RangePreset, rangePresets, STANDARD_PRESETS, } from "./toolkit/date-picker.js";
|
|
72
|
-
export { addDays, addMonths, clampDayTime, type DateRange, type DayTime, formatPattern, isDay, isDayTime, nowIn, type Preset, presetRange, todayIn, } from "./toolkit/dates.js";
|
|
73
|
-
export { DateTimePicker, type DayTimeFormat, formatDayTime } from "./toolkit/date-time-picker.js";
|
|
73
|
+
export { addDays, addMonths, clampDayTime, type DateRange, type DayTime, formatPattern, isDay, isDayTime, nowIn, parsePattern, partsOfDayTime, type Preset, presetRange, todayIn, } from "./toolkit/dates.js";
|
|
74
|
+
export { type Clock, DateTimePicker, type DayTimeFormat, formatDayTime, TimeFields, } from "./toolkit/date-time-picker.js";
|
|
74
75
|
export { LiveClock } from "./toolkit/live-clock.js";
|
|
75
76
|
export { dismissToast, toast, type ToastOptions, type ToastPlacement, Toasts, type ToastTone, } from "./toolkit/toast.js";
|
|
76
77
|
export { type Binding, shortcutLabel, useShortcuts } from "./toolkit/shortcuts.js";
|
package/hosts/web/mod.js
CHANGED
|
@@ -64,6 +64,7 @@ export { Tooltip } from "./toolkit/tooltip.js";
|
|
|
64
64
|
export { Divider, Spacer, Stack } from "./toolkit/stack.js";
|
|
65
65
|
export { Grid, GridItem } from "./toolkit/grid.js";
|
|
66
66
|
export { Toolbar } from "./toolkit/toolbar.js";
|
|
67
|
+
export { Screen } from "./toolkit/screen.js";
|
|
67
68
|
export { Split } from "./toolkit/split.js";
|
|
68
69
|
export { ListGroup } from "./toolkit/list-group.js";
|
|
69
70
|
export { Heading, Text } from "./toolkit/text.js";
|
|
@@ -78,10 +79,10 @@ export { tableAddress, tableQuery, tableState } from "./table-address.js";
|
|
|
78
79
|
export { download, EXPORT_FORMATS, exportFile, toCsv, toExcel, toJson, toPdf, toSql, toXlsx, toXml, } from "./toolkit/export.js";
|
|
79
80
|
export { documentPdf, tablePdf, textWidth, wrapText, } from "./toolkit/pdf.js";
|
|
80
81
|
// Dates: days as `YYYY-MM-DD`, in the app's format and time zone.
|
|
81
|
-
export { Calendar, formatDay } from "./toolkit/calendar.js";
|
|
82
|
+
export { Calendar, formatDay, parseDay, } from "./toolkit/calendar.js";
|
|
82
83
|
export { DatePicker, DateRangePicker, rangePresets, STANDARD_PRESETS, } from "./toolkit/date-picker.js";
|
|
83
|
-
export { addDays, addMonths, clampDayTime, formatPattern, isDay, isDayTime, nowIn, presetRange, todayIn, } from "./toolkit/dates.js";
|
|
84
|
-
export { DateTimePicker, formatDayTime } from "./toolkit/date-time-picker.js";
|
|
84
|
+
export { addDays, addMonths, clampDayTime, formatPattern, isDay, isDayTime, nowIn, parsePattern, partsOfDayTime, presetRange, todayIn, } from "./toolkit/dates.js";
|
|
85
|
+
export { DateTimePicker, formatDayTime, TimeFields, } from "./toolkit/date-time-picker.js";
|
|
85
86
|
export { LiveClock } from "./toolkit/live-clock.js";
|
|
86
87
|
// Telling: a few seconds' word over the page.
|
|
87
88
|
export { dismissToast, toast, Toasts, } from "./toolkit/toast.js";
|
|
@@ -65,6 +65,8 @@ export const toolkit = {
|
|
|
65
65
|
"toolkit.previousMonth": "Mês anterior",
|
|
66
66
|
"toolkit.previousPage": "Página anterior",
|
|
67
67
|
"toolkit.print": "Imprimir",
|
|
68
|
+
"toolkit.rangeFrom": "De",
|
|
69
|
+
"toolkit.rangeTo": "Até",
|
|
68
70
|
"toolkit.removeFile": "Remover",
|
|
69
71
|
"toolkit.removeRow": "Remover a linha {row}",
|
|
70
72
|
"toolkit.removeTag": "Remover {tag}",
|
package/hosts/web/style.d.ts
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* toolkit's own layer; a printed document's own layout (a receipt's width,
|
|
14
14
|
* an invoice's margins) is its app's CSS, the one place an app writes some.
|
|
15
15
|
*/
|
|
16
|
-
export declare const BASE = "\n@layer copilotz-base, copilotz-toolkit;\n@layer copilotz-base {\n:root {\n font: 15px/1.55 var(--font-sans);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n -webkit-text-size-adjust: 100%;\n text-size-adjust: 100%;\n}\n*, *::before, *::after { box-sizing: border-box; }\nhtml, body, #app { height: 100%; }\n/* An app's page: it never scrolls sideways or bounces as a whole (its panes scroll); a tap is a\n tap (no double-tap zoom, no grey flash), and pinching still zooms. */\nhtml, body { overflow-x: clip; overscroll-behavior: none; }\nhtml { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }\nbody { margin: 0; background: var(--background); color: var(--foreground); }\nbutton, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }\na { color: inherit; }\ncode, kbd, pre, samp { font-family: var(--font-mono); font-variant-ligatures: none; }\n:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }\n::selection { background: color-mix(in oklab, var(--primary-text) 28%, transparent); }\n.copilotz-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n/* Touch screens: text a little larger, and fields at 16px at least, so phones never zoom in on\n one you type in (Safari does under 16px). Important, so every field's size gives way. */\n@media (pointer: coarse) {\n :root { font-size: 16px; }\n input, textarea, select { font-size: max(16px, 1em) !important; }\n}\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;\n transition-duration: .01ms !important; scroll-behavior: auto !important; }\n}\n/* Printed: all of the page, without what's for working the screen. */\n@media print {\n html, body, #app { height: auto !important; overflow: visible !important; }\n .copilotz-page-full { height: auto !important; overflow: visible !important; }\n .copilotz-no-print, .copilotz-appbar, .copilotz-topbar, .copilotz-toolbar, .copilotz-toasts,\n .copilotz-table-toolbar, .copilotz-table-control, .copilotz-pagination,\n .copilotz-button, .copilotz-icon-button, .copilotz-popover, .copilotz-menu, .copilotz-tooltip,\n .copilotz-autocomplete, .copilotz-going, .copilotz-skip { display: none !important; }\n .copilotz-table-box { overflow: visible !important; }\n}\n@media not print { .copilotz-print-only { display: none !important; } }\n}\n";
|
|
16
|
+
export declare const BASE = "\n@layer copilotz-base, copilotz-toolkit;\n@layer copilotz-base {\n:root {\n font: 15px/1.55 var(--font-sans);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n -webkit-text-size-adjust: 100%;\n text-size-adjust: 100%;\n}\n*, *::before, *::after { box-sizing: border-box; }\nhtml, body, #app { height: 100%; }\n/* An app's page: it never scrolls sideways or bounces as a whole (its panes scroll); a tap is a\n tap (no double-tap zoom, no grey flash), and pinching still zooms. */\nhtml, body { overflow-x: clip; overscroll-behavior: none; }\nhtml { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }\nbody { margin: 0; background: var(--background); color: var(--foreground); }\nbutton, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }\na { color: inherit; }\ncode, kbd, pre, samp { font-family: var(--font-mono); font-variant-ligatures: none; }\n:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }\n::selection { background: color-mix(in oklab, var(--primary-text) 28%, transparent); }\n/* `hidden` hides every toolkit piece, whatever display its own rule gives it. */\n:where([class*=\"copilotz-\"])[hidden] { display: none !important; }\n.copilotz-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }\n/* Touch screens: text a little larger, and fields at 16px at least, so phones never zoom in on\n one you type in (Safari does under 16px). Important, so every field's size gives way. */\n@media (pointer: coarse) {\n :root { font-size: 16px; }\n input, textarea, select { font-size: max(16px, 1em) !important; }\n}\n@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;\n transition-duration: .01ms !important; scroll-behavior: auto !important; }\n}\n/* Printed: all of the page, without what's for working the screen. */\n@media print {\n html, body, #app { height: auto !important; overflow: visible !important; }\n .copilotz-page-full { height: auto !important; overflow: visible !important; }\n .copilotz-page-head:not(.copilotz-page-head-print), .copilotz-no-print, .copilotz-appbar, .copilotz-topbar, .copilotz-toolbar, .copilotz-toasts,\n .copilotz-table-toolbar, .copilotz-table-control, .copilotz-pagination,\n .copilotz-button, .copilotz-icon-button, .copilotz-popover, .copilotz-menu, .copilotz-tooltip,\n .copilotz-autocomplete, .copilotz-going, .copilotz-skip { display: none !important; }\n .copilotz-table-box { overflow: visible !important; }\n}\n@media not print { .copilotz-print-only { display: none !important; } }\n}\n";
|
package/hosts/web/style.js
CHANGED
|
@@ -36,6 +36,8 @@ a { color: inherit; }
|
|
|
36
36
|
code, kbd, pre, samp { font-family: var(--font-mono); font-variant-ligatures: none; }
|
|
37
37
|
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
38
38
|
::selection { background: color-mix(in oklab, var(--primary-text) 28%, transparent); }
|
|
39
|
+
/* \`hidden\` hides every toolkit piece, whatever display its own rule gives it. */
|
|
40
|
+
:where([class*="copilotz-"])[hidden] { display: none !important; }
|
|
39
41
|
.copilotz-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
|
|
40
42
|
overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
|
41
43
|
/* Touch screens: text a little larger, and fields at 16px at least, so phones never zoom in on
|
|
@@ -52,7 +54,7 @@ code, kbd, pre, samp { font-family: var(--font-mono); font-variant-ligatures: no
|
|
|
52
54
|
@media print {
|
|
53
55
|
html, body, #app { height: auto !important; overflow: visible !important; }
|
|
54
56
|
.copilotz-page-full { height: auto !important; overflow: visible !important; }
|
|
55
|
-
.copilotz-no-print, .copilotz-appbar, .copilotz-topbar, .copilotz-toolbar, .copilotz-toasts,
|
|
57
|
+
.copilotz-page-head:not(.copilotz-page-head-print), .copilotz-no-print, .copilotz-appbar, .copilotz-topbar, .copilotz-toolbar, .copilotz-toasts,
|
|
56
58
|
.copilotz-table-toolbar, .copilotz-table-control, .copilotz-pagination,
|
|
57
59
|
.copilotz-button, .copilotz-icon-button, .copilotz-popover, .copilotz-menu, .copilotz-tooltip,
|
|
58
60
|
.copilotz-autocomplete, .copilotz-going, .copilotz-skip { display: none !important; }
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Keeps a popover beside what it belongs to while it's open (a menu under
|
|
3
3
|
* its button, a tooltip over what it explains, or beside it: `end` after it,
|
|
4
4
|
* beside a rail's item, `start` before it), by script: placed when it opens and again on scroll and
|
|
5
|
-
* resize, on the other side when there's no room.
|
|
5
|
+
* resize, on the other side when there's no room. Over or under, with room on neither side, it
|
|
6
|
+
* goes on the roomier one, as tall as that room, and scrolls inside: never past the window, never
|
|
7
|
+
* over what it belongs to. Not by CSS anchor positioning: Safari's can loop on its style (a
|
|
6
8
|
* tooltip or menu whose anchor goes or hides as a page changes keeps it
|
|
7
9
|
* re-resolving, and the page hangs). Render `ANCHORED` with the popover,
|
|
8
10
|
* which carries `copilotz-anchored`.
|
|
@@ -13,8 +15,15 @@ export const ANCHORED = sheet("anchored", `.copilotz-anchored { position: fixed;
|
|
|
13
15
|
export function anchor(popover, target, { side = "bottom", align = "start", gap = 6 } = {}) {
|
|
14
16
|
popover.dataset.side = side;
|
|
15
17
|
popover.dataset.align = align;
|
|
18
|
+
/** Whether its height is the room it was given, not its own. */
|
|
19
|
+
let capped = false;
|
|
16
20
|
const place = () => {
|
|
17
21
|
const at = target.getBoundingClientRect();
|
|
22
|
+
// Measured at its own height: a cap set before is lifted, keeping where its content was scrolled.
|
|
23
|
+
const scrolled = popover.scrollTop;
|
|
24
|
+
const lifted = capped;
|
|
25
|
+
if (lifted)
|
|
26
|
+
popover.style.maxHeight = "";
|
|
18
27
|
const size = popover.getBoundingClientRect();
|
|
19
28
|
if (side === "end" || side === "start") {
|
|
20
29
|
const after = at.right + gap;
|
|
@@ -32,10 +41,20 @@ export function anchor(popover, target, { side = "bottom", align = "start", gap
|
|
|
32
41
|
return;
|
|
33
42
|
}
|
|
34
43
|
const below = at.bottom + gap;
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
const fitsBelow = below + size.height <= innerHeight;
|
|
45
|
+
const fitsAbove = at.top - gap - size.height >= 0;
|
|
46
|
+
const room = { below: innerHeight - below - 8, above: at.top - gap - 8 };
|
|
47
|
+
// Its own side when it fits there, else the other; with room on neither, the roomier one.
|
|
48
|
+
const up = fitsBelow || fitsAbove
|
|
49
|
+
? (side === "bottom" ? !fitsBelow : fitsAbove)
|
|
50
|
+
: room.above > room.below;
|
|
51
|
+
capped = !fitsBelow && !fitsAbove;
|
|
52
|
+
const height = capped ? Math.max(0, up ? room.above : room.below) : size.height;
|
|
53
|
+
if (capped)
|
|
54
|
+
popover.style.maxHeight = `${height}px`;
|
|
55
|
+
if (lifted)
|
|
56
|
+
popover.scrollTop = scrolled;
|
|
57
|
+
const top = up ? at.top - gap - height : below;
|
|
39
58
|
const left = align === "start"
|
|
40
59
|
? at.left
|
|
41
60
|
: align === "end"
|
|
@@ -44,11 +63,18 @@ export function anchor(popover, target, { side = "bottom", align = "start", gap
|
|
|
44
63
|
popover.style.top = `${Math.max(8, top)}px`;
|
|
45
64
|
popover.style.left = `${Math.max(8, Math.min(left, innerWidth - size.width - 8))}px`;
|
|
46
65
|
};
|
|
66
|
+
// Its own content scrolling doesn't move it.
|
|
67
|
+
const onScroll = (event) => {
|
|
68
|
+
if (!(event.target instanceof Node && popover.contains(event.target)))
|
|
69
|
+
place();
|
|
70
|
+
};
|
|
47
71
|
place();
|
|
48
|
-
addEventListener("scroll",
|
|
72
|
+
addEventListener("scroll", onScroll, true);
|
|
49
73
|
addEventListener("resize", place);
|
|
50
74
|
return () => {
|
|
51
|
-
removeEventListener("scroll",
|
|
75
|
+
removeEventListener("scroll", onScroll, true);
|
|
52
76
|
removeEventListener("resize", place);
|
|
77
|
+
if (capped)
|
|
78
|
+
popover.style.maxHeight = "";
|
|
53
79
|
};
|
|
54
80
|
}
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
* a bright rounded square, a space's in a soft one, an org's initials (two,
|
|
4
4
|
* from its first words) on a tile of its own; or, given an `icon` (an
|
|
5
5
|
* emoji: an agent's), that on a soft tile of its color. Given a `picture`
|
|
6
|
-
* (a person's photo, from where they signed in: an `https:` address
|
|
7
|
-
* path on the app's own origin
|
|
8
|
-
*
|
|
6
|
+
* (a person's photo, from where they signed in: an `https:` address, a
|
|
7
|
+
* path on the app's own origin, or an image chosen but not yet sent: a
|
|
8
|
+
* `blob:` URL or a png, jpeg, gif or webp `data:` URL), that, with the
|
|
9
|
+
* initial until it loads and if it fails. `initial={false}` draws no initial:
|
|
10
|
+
* an empty box (soft, outlined) until the picture is there. The color comes from the name (or a `tint` given: an org's
|
|
9
11
|
* id, so renaming it keeps its colour), so someone looks the same
|
|
10
12
|
* everywhere. Decorative: say the name beside it.
|
|
11
13
|
*/
|
|
12
14
|
import { type ReactNode } from "react";
|
|
13
|
-
export declare function Avatar({ name, kind, size, icon, picture, tint, title, className }: {
|
|
15
|
+
export declare function Avatar({ name, kind, size, icon, picture, initial, tint, title, className }: {
|
|
14
16
|
name: string;
|
|
15
17
|
kind?: "person" | "agent" | "space" | "org";
|
|
16
18
|
size?: number;
|
|
@@ -18,6 +20,8 @@ export declare function Avatar({ name, kind, size, icon, picture, tint, title, c
|
|
|
18
20
|
icon?: string;
|
|
19
21
|
/** A photo to show instead: a person's, from their sign-in. */
|
|
20
22
|
picture?: string;
|
|
23
|
+
/** Draw the initial (yes); `false`: an empty box with no picture. */
|
|
24
|
+
initial?: boolean;
|
|
21
25
|
/** What the colour comes from, when not the name: an id that never changes. */
|
|
22
26
|
tint?: string;
|
|
23
27
|
title?: string;
|
|
@@ -4,9 +4,11 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
4
4
|
* a bright rounded square, a space's in a soft one, an org's initials (two,
|
|
5
5
|
* from its first words) on a tile of its own; or, given an `icon` (an
|
|
6
6
|
* emoji: an agent's), that on a soft tile of its color. Given a `picture`
|
|
7
|
-
* (a person's photo, from where they signed in: an `https:` address
|
|
8
|
-
* path on the app's own origin
|
|
9
|
-
*
|
|
7
|
+
* (a person's photo, from where they signed in: an `https:` address, a
|
|
8
|
+
* path on the app's own origin, or an image chosen but not yet sent: a
|
|
9
|
+
* `blob:` URL or a png, jpeg, gif or webp `data:` URL), that, with the
|
|
10
|
+
* initial until it loads and if it fails. `initial={false}` draws no initial:
|
|
11
|
+
* an empty box (soft, outlined) until the picture is there. The color comes from the name (or a `tint` given: an org's
|
|
10
12
|
* id, so renaming it keeps its colour), so someone looks the same
|
|
11
13
|
* everywhere. Decorative: say the name beside it.
|
|
12
14
|
*/
|
|
@@ -41,6 +43,8 @@ const SHEET = sheet("avatar", `
|
|
|
41
43
|
.copilotz-avatar:not(.copilotz-avatar-agent, .copilotz-avatar-org) { background: hsl(var(--hue) 32% 25%); color: hsl(var(--hue) 85% 86%); }
|
|
42
44
|
.copilotz-avatar.copilotz-avatar-icon { background: hsl(var(--hue) 30% 22%); box-shadow: inset 0 0 0 1px hsl(var(--hue) 30% 30%); }
|
|
43
45
|
}
|
|
46
|
+
.copilotz-avatar.copilotz-avatar-empty { background: var(--avatar-empty-background, var(--muted)); color: inherit;
|
|
47
|
+
box-shadow: inset 0 0 0 1px var(--avatar-empty-border-color, var(--border)); }
|
|
44
48
|
`);
|
|
45
49
|
/** The first character as people see one (an emoji with its modifiers is one). */
|
|
46
50
|
let graphemes;
|
|
@@ -57,14 +61,21 @@ const initials = (name) => {
|
|
|
57
61
|
return letters.filter(Boolean).join("").toUpperCase() || "?";
|
|
58
62
|
};
|
|
59
63
|
/** A picture shown only from where it may come: the web, securely, or the app's own origin. */
|
|
60
|
-
const pictureOf = (src) => src &&
|
|
61
|
-
|
|
64
|
+
const pictureOf = (src) => src &&
|
|
65
|
+
(/^https:\/\/[^\s"'<>]+$/.test(src) || /^\/(?!\/)[^\s"'<>]*$/.test(src) ||
|
|
66
|
+
// A picked image not yet sent: an object URL, or a small image's own data.
|
|
67
|
+
/^blob:[^\s"'<>]+$/.test(src) ||
|
|
68
|
+
/^data:image\/(?:png|jpeg|gif|webp)(?:;base64)?,[^\s"'<>]*$/.test(src))
|
|
69
|
+
? src
|
|
70
|
+
: undefined;
|
|
71
|
+
export function Avatar({ name, kind = "person", size = 28, icon, picture, initial = true, tint, title, className }) {
|
|
62
72
|
const [failed, setFailed] = useState();
|
|
63
73
|
const glyph = icon?.trim() ? first(icon.trim()) : undefined;
|
|
64
74
|
const src = pictureOf(picture);
|
|
65
75
|
const photo = src && failed !== src ? src : undefined;
|
|
76
|
+
const empty = !initial && !glyph && !photo;
|
|
66
77
|
const letters = kind === "org" ? initials(name) : (first(name.trim()) ?? "?").toUpperCase();
|
|
67
|
-
return (_jsxs(_Fragment, { children: [SHEET, _jsxs("span", { className: `copilotz-avatar copilotz-avatar-${kind}${glyph ? " copilotz-avatar-icon" : ""}${photo ? " copilotz-avatar-picture" : ""}${className ? ` ${className}` : ""}`, style: { "--hue": hue(tint ?? name), "--size": `${size}px` }, title: title, "aria-hidden": "true", children: [glyph ?? letters, photo
|
|
78
|
+
return (_jsxs(_Fragment, { children: [SHEET, _jsxs("span", { className: `copilotz-avatar copilotz-avatar-${kind}${glyph ? " copilotz-avatar-icon" : ""}${photo ? " copilotz-avatar-picture" : ""}${empty ? " copilotz-avatar-empty" : ""}${className ? ` ${className}` : ""}`, style: { "--hue": hue(tint ?? name), "--size": `${size}px` }, title: title, "aria-hidden": "true", children: [glyph ?? (initial ? letters : null), photo
|
|
68
79
|
? (_jsx("img", { src: photo, alt: "", referrerPolicy: "no-referrer", loading: "lazy", decoding: "async", onError: () => setFailed(photo) }))
|
|
69
80
|
: null] })] }));
|
|
70
81
|
}
|
|
@@ -33,6 +33,12 @@ export type CalendarValue = string | {
|
|
|
33
33
|
export declare function weekStartOf(locale: string): number;
|
|
34
34
|
/** A day written by a format: the pattern's, the function's, or the page language's short date. */
|
|
35
35
|
export declare function formatDay(day: string, format?: DayFormat): string;
|
|
36
|
+
/**
|
|
37
|
+
* A day read from text typed in the same format `formatDay` writes (a pattern, or the page
|
|
38
|
+
* language's short date), or `undefined` when it isn't a real day. A function format can't be
|
|
39
|
+
* turned back, so its text is read as the page language's short date, or as `YYYY-MM-DD`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseDay(text: string, format?: DayFormat): string | undefined;
|
|
36
42
|
export declare function Calendar({ month, onMonth, months, value, onPick, min, max, today, weekStart, monthFormat, label, className, }: {
|
|
37
43
|
/** The (first) month shown: `YYYY-MM`, or any of its days. */
|
|
38
44
|
month: string;
|