@mccaskie-labs/workbench-contacts 0.3.0 → 0.4.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/CHANGELOG.md +12 -0
- package/dist/confirm.js +3 -1
- package/dist/samples.d.ts +18 -0
- package/dist/samples.js +53 -0
- package/dist/ui.js +2 -2
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mccaskie-labs/workbench-contacts
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Samples at `./samples` for the style guide (docs/look-studio.md §5.1): the owner's list of customers and one customer's page, drawn by the tool's own renderers with made-up data.
|
|
8
|
+
|
|
9
|
+
## 0.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Short answers get sensible widths in every tool (Robert, 24 November 2026). A tool's own one-line fields for an email, a phone number, a date, a time, a small number, an amount or a postcode now carry workbench-ui's `wb-ui-size-<n>` class, so they are about as wide as what they hold instead of the full width, and never wider than their column. The "type this word to confirm" box in "Are you sure?" is as wide as its word. Names, addresses and other long text keep the full width. A project restyles the widths in project.css by the same class names. Needs workbench-ui 0.10.0 or later in the project, whose workbench.css carries the classes.
|
|
14
|
+
|
|
3
15
|
## 0.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/confirm.js
CHANGED
|
@@ -18,8 +18,10 @@ export function renderConfirm(o) {
|
|
|
18
18
|
const reason = o.reason
|
|
19
19
|
? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.reason.label)}</span><input class="${p}-confirm-input" type="text" name="${esc(o.reason.name ?? "reason")}" maxlength="${o.reason.maxlength ?? 200}"${o.reason.required ? " required" : ""}></label>`
|
|
20
20
|
: "";
|
|
21
|
+
// The word box is as wide as the word (workbench-ui's wb-ui-size-<n>, in characters), not the width of the page.
|
|
22
|
+
const wordSize = o.type ? [5, 6, 8, 10, 12, 14, 16, 20, 24, 30, 40].find((n) => n > o.type.word.length) : undefined;
|
|
21
23
|
const type = o.type
|
|
22
|
-
? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
|
|
24
|
+
? `<label class="${p}-confirm-field"><span class="${p}-confirm-label">${esc(o.type.label)}</span><input class="${p}-confirm-input${wordSize ? ` wb-ui-size-${wordSize}` : ""}" type="text" name="confirm_word" required pattern="${esc(pattern(o.type.word))}" autocomplete="off" autocapitalize="off" spellcheck="false"></label>`
|
|
23
25
|
: "";
|
|
24
26
|
return `<details class="${p}-confirm"${o.open ? " open" : ""}><summary class="${p}-confirm-open ${esc(o.askClass)}"><span class="${p}-confirm-ask">${esc(o.ask)}</span><span class="${p}-confirm-keep">${esc(o.no)}</span></summary><form class="${p}-confirm-form" method="post" action="${esc(o.endpoint)}">${hidden}<p class="${p}-confirm-question">${esc(o.question)}</p>${o.consequence ? `<p class="${p}-confirm-consequence">${esc(o.consequence)}</p>` : ""}${reason}${o.extra ?? ""}${type}<button class="${p}-confirm-yes" type="submit">${esc(o.yes)}</button></form></details>`;
|
|
25
27
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One sample: a part of the tool, or one of its layouts. */
|
|
2
|
+
interface ToolSample {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
layout?: string;
|
|
6
|
+
html: () => string;
|
|
7
|
+
}
|
|
8
|
+
/** Every sample of one tool (workbench-ui's ToolSamples). */
|
|
9
|
+
export interface ToolSamples {
|
|
10
|
+
format: 1;
|
|
11
|
+
package: string;
|
|
12
|
+
title: string;
|
|
13
|
+
prefix: string;
|
|
14
|
+
samples: readonly ToolSample[];
|
|
15
|
+
}
|
|
16
|
+
/** Every sample of the contacts tool. */
|
|
17
|
+
export declare const CONTACT_SAMPLES: ToolSamples;
|
|
18
|
+
export {};
|
package/dist/samples.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The contacts tool's samples (docs/look-studio.md §5.1): the owner's list of
|
|
2
|
+
// customers and one customer's page, with made-up data, for the project's
|
|
3
|
+
// style guide, the look previewer and the visual check. Drawn by the tool's
|
|
4
|
+
// own renderers.
|
|
5
|
+
import { CONTACT_STYLES } from "./styles.js";
|
|
6
|
+
import { renderContact, renderContactList } from "./ui.js";
|
|
7
|
+
const contact = (id, over = {}) => ({
|
|
8
|
+
id,
|
|
9
|
+
account: "studio",
|
|
10
|
+
name: "Maria Santos",
|
|
11
|
+
email: "maria@example.com",
|
|
12
|
+
phone: "0400 000 000",
|
|
13
|
+
messenger: null,
|
|
14
|
+
marketing: "yes",
|
|
15
|
+
marketing_at: "2026-11-01T00:00:00.000Z",
|
|
16
|
+
marketing_source: "form",
|
|
17
|
+
marketing_wording: "Send me news and offers",
|
|
18
|
+
note: "Prefers the early class.",
|
|
19
|
+
first_seen_at: "2026-03-02T00:00:00.000Z",
|
|
20
|
+
last_seen_at: "2026-11-20T00:00:00.000Z",
|
|
21
|
+
counts: { booking: 1, form: 1 },
|
|
22
|
+
...over,
|
|
23
|
+
});
|
|
24
|
+
const people = [contact("c1"), contact("c2", { name: "Jordan Lee", email: "jordan@example.com", phone: null, marketing: "unknown" }), contact("c3", { name: null, email: "sam@example.com", phone: null, marketing: "no" })];
|
|
25
|
+
const detail = {
|
|
26
|
+
...people[0],
|
|
27
|
+
events: [
|
|
28
|
+
{ kind: "booking", type: "booking", id: "b1", at: "2026-11-20T00:00:00.000Z" },
|
|
29
|
+
{ kind: "form", type: "enquiry", id: "e1", at: "2026-03-02T00:00:00.000Z" },
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
const common = { timeZone: "Australia/Sydney" };
|
|
33
|
+
/** Every sample of the contacts tool. */
|
|
34
|
+
export const CONTACT_SAMPLES = {
|
|
35
|
+
format: 1,
|
|
36
|
+
package: CONTACT_STYLES.package,
|
|
37
|
+
title: "Contacts",
|
|
38
|
+
prefix: CONTACT_STYLES.prefix,
|
|
39
|
+
samples: [
|
|
40
|
+
{
|
|
41
|
+
id: "list",
|
|
42
|
+
title: "The owner's list of customers",
|
|
43
|
+
html: () => renderContactList({ total: 42, contacts: people, next: 3 }, { ...common, endpoint: "/admin/contacts", contactUrl: (c) => `/admin/contacts/${c.id}`, exportUrl: "/admin/contacts.csv", mailingListUrl: "/admin/contacts.csv?marketing=yes" }),
|
|
44
|
+
},
|
|
45
|
+
{ id: "empty", title: "A search that finds no one", html: () => renderContactList({ total: 0, contacts: [] }, { ...common, endpoint: "/admin/contacts", contactUrl: () => "#", query: "Zed" }) },
|
|
46
|
+
{
|
|
47
|
+
id: "contact",
|
|
48
|
+
title: "One customer's page, just saved",
|
|
49
|
+
html: () => renderContact(detail, { ...common, endpoint: "/admin/contacts", downloadUrl: "/admin/contacts/c1.json", keep: ["name", "email", "phone", "messenger"], marketing: true, done: "save", emails: true }),
|
|
50
|
+
},
|
|
51
|
+
{ id: "no-history", title: "A customer with nothing yet", html: () => renderContact({ ...people[2], events: [] }, { ...common, endpoint: "/admin/contacts", keep: ["email"], notes: false }) },
|
|
52
|
+
],
|
|
53
|
+
};
|
package/dist/ui.js
CHANGED
|
@@ -33,7 +33,7 @@ const withParam = (url, key, value) => `${url}${url.includes("?") ? "&" : "?"}${
|
|
|
33
33
|
export function renderContactList(r, o) {
|
|
34
34
|
const w = words(o);
|
|
35
35
|
const q = o.query?.trim() ?? "";
|
|
36
|
-
const search = `<form class="wb-contact-search" method="get" action="${esc(o.endpoint)}" role="search"><label class="wb-contact-search-label" for="wb-contact-q">${esc(w("search.label"))}</label><input class="wb-contact-query" id="wb-contact-q" type="search" name="q" value="${esc(q)}" maxlength="100" autocomplete="off"><button class="wb-contact-find" type="submit">${esc(w("search.button"))}</button></form>`;
|
|
36
|
+
const search = `<form class="wb-contact-search" method="get" action="${esc(o.endpoint)}" role="search"><label class="wb-contact-search-label" for="wb-contact-q">${esc(w("search.label"))}</label><input class="wb-contact-query wb-ui-size-30" id="wb-contact-q" type="search" name="q" value="${esc(q)}" maxlength="100" autocomplete="off"><button class="wb-contact-find" type="submit">${esc(w("search.button"))}</button></form>`;
|
|
37
37
|
const exports = [
|
|
38
38
|
o.exportUrl ? `<a class="wb-contact-export" href="${esc(o.exportUrl)}" download>${esc(w("export.all"))}</a>` : "",
|
|
39
39
|
o.mailingListUrl ? `<a class="wb-contact-export" href="${esc(o.mailingListUrl)}" download>${esc(w("export.marketing"))}</a>` : "",
|
|
@@ -63,7 +63,7 @@ export function renderContact(c, o) {
|
|
|
63
63
|
fact(w("field.last_seen"), dateText(c.last_seen_at, o)),
|
|
64
64
|
].join("");
|
|
65
65
|
const field = (name, type, auto) => o.keep.includes(name)
|
|
66
|
-
? `<div class="wb-contact-field"><label class="wb-contact-label" for="wb-contact-${name}">${esc(w(`field.${name}`))}</label><input class="wb-contact-input" id="wb-contact-${name}" type="${type}" name="${name}" value="${esc(c[name] ?? "")}" autocomplete="${auto}"${name === "messenger" ? ' inputmode="numeric"' : ""}></div>`
|
|
66
|
+
? `<div class="wb-contact-field"><label class="wb-contact-label" for="wb-contact-${name}">${esc(w(`field.${name}`))}</label><input class="wb-contact-input${name === "email" ? " wb-ui-size-30" : name === "phone" ? " wb-ui-size-16" : name === "messenger" ? " wb-ui-size-20" : ""}" id="wb-contact-${name}" type="${type}" name="${name}" value="${esc(c[name] ?? "")}" autocomplete="${auto}"${name === "messenger" ? ' inputmode="numeric"' : ""}></div>`
|
|
67
67
|
: "";
|
|
68
68
|
const note = o.notes !== false
|
|
69
69
|
? `<div class="wb-contact-field"><label class="wb-contact-label" for="wb-contact-note">${esc(w("field.note"))}</label><textarea class="wb-contact-note" id="wb-contact-note" name="note" maxlength="1000" rows="3">${esc(c.note ?? "")}</textarea></div>`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-contacts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Simple customer records for Workbench apps: one list of the people a business deals with, kept in the app's own database and filled from its forms, bookings, payments, quotes, reviews and WhatsApp and Messenger messages, with search, a spreadsheet export, a person's own copy on request, opt-outs that stick, and a clean-up of people who haven't been back.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"types": "./dist/styles.d.ts",
|
|
23
23
|
"default": "./dist/styles.js"
|
|
24
24
|
},
|
|
25
|
+
"./samples": {
|
|
26
|
+
"types": "./dist/samples.d.ts",
|
|
27
|
+
"default": "./dist/samples.js"
|
|
28
|
+
},
|
|
25
29
|
"./package.json": "./package.json"
|
|
26
30
|
},
|
|
27
31
|
"bin": {
|