@tristan2828/ui-foundation 4.95.0 → 4.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conventions/AGENTS.md +1 -1
- package/conventions/docs/add-an-entity.md +46 -25
- package/conventions/docs/cell-patterns.md +61 -57
- package/conventions/docs/design-language.md +91 -42
- package/conventions/docs/reminders.md +2 -2
- package/conventions/docs/timed-screens.md +1 -1
- package/dist/components/app/action-error.js +1 -1
- package/dist/components/app/allow-reminders.js +1 -1
- package/dist/components/app/app-shell.js +4 -4
- package/dist/components/app/board.js +1 -1
- package/dist/components/app/choice-buttons.js +6 -1
- package/dist/components/app/data-table-tools.js +2 -2
- package/dist/components/app/data-table.js +4 -4
- package/dist/components/app/date-field.js +1 -1
- package/dist/components/app/delete-action.d.ts +16 -3
- package/dist/components/app/delete-action.js +21 -4
- package/dist/components/app/emoji-field-data.js +7 -7
- package/dist/components/app/empty-value.d.ts +10 -3
- package/dist/components/app/empty-value.js +3 -8
- package/dist/components/app/entity-form.js +1 -1
- package/dist/components/app/entity-view.js +5 -5
- package/dist/components/app/error-state.js +1 -1
- package/dist/components/app/field-rows.js +6 -3
- package/dist/components/app/fill-in-queue.js +2 -2
- package/dist/components/app/filter-bar.js +1 -1
- package/dist/components/app/form-dialog.js +1 -1
- package/dist/components/app/form-section.d.ts +1 -1
- package/dist/components/app/image-field.js +3 -2
- package/dist/components/app/list-header.js +2 -2
- package/dist/components/app/milkdown-editor.js +4 -4
- package/dist/components/app/module-card.js +2 -1
- package/dist/components/app/month-day-field.js +3 -3
- package/dist/components/app/multi-pick.js +1 -1
- package/dist/components/app/needs-you.js +1 -1
- package/dist/components/app/notes-outline.js +1 -1
- package/dist/components/app/overview-page.js +2 -1
- package/dist/components/app/password-input.js +1 -1
- package/dist/components/app/record-dialog.js +1 -1
- package/dist/components/app/rich-text-format-items.js +6 -6
- package/dist/components/app/rich-text-highlight-menu.js +1 -1
- package/dist/components/app/rich-text-table-grips.js +16 -16
- package/dist/components/app/rich-text-toolbar.js +2 -2
- package/dist/components/app/rich-text-widgets.js +2 -2
- package/dist/components/app/secondary-filters.js +2 -2
- package/dist/components/app/session-view.js +1 -1
- package/dist/components/app/timeline.js +1 -1
- package/dist/components/app/value-list.js +2 -1
- package/dist/components/app/widget-card.js +2 -1
- package/dist/components/app/widget-layout-sheet.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -0
- package/dist/lib/group-by-day.js +2 -2
- package/dist/lib/title-case.d.ts +13 -0
- package/dist/lib/title-case.js +66 -0
- package/dist/routes/login.js +4 -4
- package/dist/routes/register.js +1 -1
- package/package.json +1 -1
package/dist/lib/group-by-day.js
CHANGED
|
@@ -26,7 +26,7 @@ export function byDay(field, { now = new Date(), timeZone, weekStartsOn = 1, loc
|
|
|
26
26
|
const value = read(row);
|
|
27
27
|
const date = value === null || value === undefined || value === '' ? null : new Date(value);
|
|
28
28
|
if (date === null || Number.isNaN(date.getTime()))
|
|
29
|
-
return { key: 'none', label: 'No
|
|
29
|
+
return { key: 'none', label: 'No Date' };
|
|
30
30
|
const day = dayOf(date);
|
|
31
31
|
if (day > today)
|
|
32
32
|
return { key: 'upcoming', label: 'Upcoming' };
|
|
@@ -35,7 +35,7 @@ export function byDay(field, { now = new Date(), timeZone, weekStartsOn = 1, loc
|
|
|
35
35
|
if (day === today - 1)
|
|
36
36
|
return { key: 'yesterday', label: 'Yesterday' };
|
|
37
37
|
if (day >= thisWeek)
|
|
38
|
-
return { key: 'this-week', label: 'Earlier
|
|
38
|
+
return { key: 'this-week', label: 'Earlier This Week' };
|
|
39
39
|
const week = weekStart(day);
|
|
40
40
|
if (week >= thisWeek - WEEKS_BY_WEEK * 7) {
|
|
41
41
|
return { key: `week:${isoDay(week)}`, label: `Week of ${dayMonth.format(new Date(week * DAY_MS))}` };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The short words a title keeps lowercase, unless first or last. */
|
|
2
|
+
export declare const TITLE_CASE_SMALL_WORDS: ReadonlySet<string>;
|
|
3
|
+
/**
|
|
4
|
+
* A label in Title Case: every word capitalised but the short ones
|
|
5
|
+
* (`TITLE_CASE_SMALL_WORDS`: a, an, the, and, or, of, to, in, on, for, by,
|
|
6
|
+
* with, ...), which stay lowercase unless first or last, or first after a
|
|
7
|
+
* colon. A word that already holds a capital is left as written, so names
|
|
8
|
+
* and acronyms survive: `titleCase('rows per page')` is "Rows per Page",
|
|
9
|
+
* `titleCase('move to')` is "Move To", `titleCase('open in GitHub')` is
|
|
10
|
+
* "Open in GitHub". For a label built from a value (`Any ${label}`); a
|
|
11
|
+
* label written in the code is written in Title Case to begin with.
|
|
12
|
+
*/
|
|
13
|
+
export declare function titleCase(text: string): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The words a label is written in (design-language.md "Words on screen"):
|
|
2
|
+
// titles, buttons, menu items, tabs, column headers and field labels are
|
|
3
|
+
// Title Case. Messages, help text, toasts, placeholders and screen-reader
|
|
4
|
+
// sentences stay sentence case, so they never go through this.
|
|
5
|
+
/** The short words a title keeps lowercase, unless first or last. */
|
|
6
|
+
export const TITLE_CASE_SMALL_WORDS = new Set([
|
|
7
|
+
'a',
|
|
8
|
+
'an',
|
|
9
|
+
'the',
|
|
10
|
+
'and',
|
|
11
|
+
'but',
|
|
12
|
+
'or',
|
|
13
|
+
'nor',
|
|
14
|
+
'as',
|
|
15
|
+
'at',
|
|
16
|
+
'by',
|
|
17
|
+
'for',
|
|
18
|
+
'in',
|
|
19
|
+
'of',
|
|
20
|
+
'on',
|
|
21
|
+
'per',
|
|
22
|
+
'to',
|
|
23
|
+
'with',
|
|
24
|
+
]);
|
|
25
|
+
const upperFirst = (part) => part.replace(/\p{L}/u, (letter) => letter.toUpperCase());
|
|
26
|
+
function casePart(part, edge) {
|
|
27
|
+
if (!/\p{L}/u.test(part))
|
|
28
|
+
return part;
|
|
29
|
+
// A word already holding a capital ("iPhone", "URL", "McKay") is written as its owner wrote it.
|
|
30
|
+
if (/\p{Lu}/u.test(part))
|
|
31
|
+
return part;
|
|
32
|
+
const bare = part.replace(/^[^\p{L}]+|[^\p{L}]+$/gu, '');
|
|
33
|
+
if (!edge && TITLE_CASE_SMALL_WORDS.has(bare))
|
|
34
|
+
return part;
|
|
35
|
+
return upperFirst(part);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A label in Title Case: every word capitalised but the short ones
|
|
39
|
+
* (`TITLE_CASE_SMALL_WORDS`: a, an, the, and, or, of, to, in, on, for, by,
|
|
40
|
+
* with, ...), which stay lowercase unless first or last, or first after a
|
|
41
|
+
* colon. A word that already holds a capital is left as written, so names
|
|
42
|
+
* and acronyms survive: `titleCase('rows per page')` is "Rows per Page",
|
|
43
|
+
* `titleCase('move to')` is "Move To", `titleCase('open in GitHub')` is
|
|
44
|
+
* "Open in GitHub". For a label built from a value (`Any ${label}`); a
|
|
45
|
+
* label written in the code is written in Title Case to begin with.
|
|
46
|
+
*/
|
|
47
|
+
export function titleCase(text) {
|
|
48
|
+
const words = text.split(/(\s+)/);
|
|
49
|
+
const real = words.map((word, index) => (index % 2 === 0 && word !== '' ? index : -1)).filter((index) => index >= 0);
|
|
50
|
+
const first = real[0];
|
|
51
|
+
const last = real.at(-1);
|
|
52
|
+
let afterColon = false;
|
|
53
|
+
return words
|
|
54
|
+
.map((word, index) => {
|
|
55
|
+
if (index % 2 === 1 || word === '')
|
|
56
|
+
return word;
|
|
57
|
+
const edge = index === first || index === last || afterColon;
|
|
58
|
+
afterColon = /:$/.test(word);
|
|
59
|
+
return word
|
|
60
|
+
.split('-')
|
|
61
|
+
// Each part of a hyphenated word is a word ("Follow-Up"), small or not.
|
|
62
|
+
.map((part, partIndex) => casePart(part, edge || partIndex > 0))
|
|
63
|
+
.join('-');
|
|
64
|
+
})
|
|
65
|
+
.join('');
|
|
66
|
+
}
|
package/dist/routes/login.js
CHANGED
|
@@ -59,7 +59,7 @@ export function LoginRoute({ registerPath = '/register' } = {}) {
|
|
|
59
59
|
setStep('password');
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Sign
|
|
62
|
+
return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Sign In" }) }), step === 'code' && _jsx(CardDescription, { children: "Your account has two-step sign-in." })] }), _jsx(CardContent, { children: step === 'password' ? (_jsx(PasswordStep, { registerPath: registerPath, restartReason: restartReason, onResult: onResult })) : (_jsx(CodeStep, { onResult: onResult, onStartOver: () => {
|
|
63
63
|
setRestartReason(null);
|
|
64
64
|
setStep('password');
|
|
65
65
|
} })) })] }) }));
|
|
@@ -98,7 +98,7 @@ function PasswordStep({ registerPath, restartReason, onResult, }) {
|
|
|
98
98
|
setIsSubmitting(false);
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [restartReason && _jsx(FieldError, { children: restartReason }), _jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "login-email", children: "Email" }), _jsx(Input, { id: "login-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "login-password", children: "Password" }), _jsx(PasswordInput, { id: "login-password", autoComplete: "current-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Sign
|
|
101
|
+
return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [restartReason && _jsx(FieldError, { children: restartReason }), _jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "login-email", children: "Email" }), _jsx(Input, { id: "login-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "login-password", children: "Password" }), _jsx(PasswordInput, { id: "login-password", autoComplete: "current-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Sign In"] }), registerPath !== null && (_jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: registerPath, state: location.state }), children: "Create Account" }))] }));
|
|
102
102
|
}
|
|
103
103
|
function CodeStep({ onResult, onStartOver, }) {
|
|
104
104
|
const [recovery, setRecovery] = useState(false);
|
|
@@ -138,7 +138,7 @@ function CodeForm({ recovery, onSwitchMode, onResult, onStartOver, }) {
|
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
140
|
const invalid = !!form.formState.errors.code;
|
|
141
|
-
return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsx(FieldGroup, { children: _jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: "login-code", children: recovery ? 'Recovery
|
|
141
|
+
return (_jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsx(FieldGroup, { children: _jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: "login-code", children: recovery ? 'Recovery Code' : 'Authentication Code' }), _jsx(Input, { id: "login-code", autoComplete: recovery ? 'off' : 'one-time-code', inputMode: recovery ? 'text' : 'numeric', spellCheck: false, "aria-invalid": invalid, "aria-describedby": "login-code-description", ...form.register('code') }), _jsx(FieldDescription, { id: "login-code-description", children: recovery
|
|
142
142
|
? 'One of the recovery codes you saved when two-step sign-in was turned on. Each works once.'
|
|
143
|
-
: 'The 6-digit code your authenticator app shows for this account.' }), _jsx(FieldError, { errors: [form.formState.errors.code] })] }) }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Verify"] }), _jsxs("div", { className: "flex flex-wrap justify-between gap-2", children: [_jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onSwitchMode, children: recovery ? 'Use
|
|
143
|
+
: 'The 6-digit code your authenticator app shows for this account.' }), _jsx(FieldError, { errors: [form.formState.errors.code] })] }) }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting || held, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Verify"] }), _jsxs("div", { className: "flex flex-wrap justify-between gap-2", children: [_jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onSwitchMode, children: recovery ? 'Use Your Authenticator App' : 'Use a Recovery Code' }), _jsx(Button, { type: "button", variant: "link", size: "sm", onClick: onStartOver, children: "Start Over" })] })] }));
|
|
144
144
|
}
|
package/dist/routes/register.js
CHANGED
|
@@ -54,5 +54,5 @@ export function RegisterRoute() {
|
|
|
54
54
|
setIsSubmitting(false);
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Create an
|
|
57
|
+
return (_jsx("main", { className: "flex min-h-screen items-center justify-center bg-background p-6", children: _jsxs(Card, { className: "w-full max-w-sm", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-lg", children: _jsx("h1", { children: "Create an Account" }) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: onSubmit, noValidate: true, className: "flex flex-col gap-6", children: [_jsxs(FieldGroup, { children: [_jsxs(Field, { "data-invalid": !!form.formState.errors.name, children: [_jsx(FieldLabel, { htmlFor: "register-name", children: "Name" }), _jsx(Input, { id: "register-name", autoComplete: "name", "aria-invalid": !!form.formState.errors.name, ...form.register('name') }), _jsx(FieldError, { errors: [form.formState.errors.name] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.email, children: [_jsx(FieldLabel, { htmlFor: "register-email", children: "Email" }), _jsx(Input, { id: "register-email", type: "email", autoComplete: "username", "aria-invalid": !!form.formState.errors.email, ...form.register('email') }), _jsx(FieldError, { errors: [form.formState.errors.email] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.password, children: [_jsx(FieldLabel, { htmlFor: "register-password", children: "Password" }), _jsx(PasswordInput, { id: "register-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.password, ...form.register('password') }), _jsx(FieldError, { errors: [form.formState.errors.password] })] }), _jsxs(Field, { "data-invalid": !!form.formState.errors.confirmPassword, children: [_jsx(FieldLabel, { htmlFor: "register-confirm-password", children: "Confirm Password" }), _jsx(PasswordInput, { id: "register-confirm-password", autoComplete: "new-password", "aria-invalid": !!form.formState.errors.confirmPassword, ...form.register('confirmPassword') }), _jsx(FieldError, { errors: [form.formState.errors.confirmPassword] })] })] }), submitError && _jsx(ErrorState, { error: submitError }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting && _jsx(Spinner, { className: "size-4" }), "Create Account"] }), _jsx(Button, { variant: "link", size: "sm", nativeButton: false, render: _jsx(Link, { to: "/login", state: location.state }), children: "Sign In Instead" })] }) })] }) }));
|
|
58
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.97.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|