@tristan2828/ui-foundation 4.120.0 → 4.122.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/components/app/milkdown-editor.js +4 -1
- package/dist/components/app/rich-text-empty-paragraph.d.ts +10 -0
- package/dist/components/app/rich-text-empty-paragraph.js +26 -0
- package/dist/hooks/use-is-phone.js +1 -1
- package/dist/hooks/use-mobile.js +6 -12
- package/dist/testing/index.js +1 -18
- package/dist/testing/transitions.d.ts +11 -0
- package/dist/testing/transitions.js +18 -0
- package/package.json +27 -27
|
@@ -76,7 +76,7 @@ import { createPortal } from 'react-dom';
|
|
|
76
76
|
import { useInRouterContext, useNavigate } from 'react-router';
|
|
77
77
|
import { defaultValueCtx, Editor, editorViewCtx, editorViewOptionsCtx, parserCtx, remarkStringifyOptionsCtx, rootCtx, schemaCtx, serializerCtx, } from '@milkdown/kit/core';
|
|
78
78
|
import { history } from '@milkdown/kit/plugin/history';
|
|
79
|
-
import { commands, headingSchema, inputRules, keymap, markInputRules, plugins, remarkPreserveEmptyLinePlugin, schema, } from '@milkdown/kit/preset/commonmark';
|
|
79
|
+
import { commands, headingSchema, paragraphSchema, inputRules, keymap, markInputRules, plugins, remarkPreserveEmptyLinePlugin, schema, } from '@milkdown/kit/preset/commonmark';
|
|
80
80
|
import { gfm, tableCellSchema, tableHeaderSchema, tableSchema } from '@milkdown/kit/preset/gfm';
|
|
81
81
|
import { Fragment, Slice } from '@milkdown/kit/prose/model';
|
|
82
82
|
import { NodeSelection, Plugin, TextSelection } from '@milkdown/kit/prose/state';
|
|
@@ -110,6 +110,7 @@ import { calloutKind, calloutView, tableView } from './rich-text-node-views.js';
|
|
|
110
110
|
import { droppedFiles, imageUploadPlugin, pastedImages, uploadImages, uploadPlaceholders } from './rich-text-image-upload.js';
|
|
111
111
|
import { handleShortcut } from './rich-text-shortcuts.js';
|
|
112
112
|
import { splitTaskItem, taskInputRule } from './rich-text-tasks.js';
|
|
113
|
+
import { withEmptyParagraphChildren } from './rich-text-empty-paragraph.js';
|
|
113
114
|
import { toggleHeadingInputRule, toggleHeadingRemark, withToggle } from './rich-text-toggle-heading.js';
|
|
114
115
|
import { addRowAtEnd, colorTableCells, fitAllColumns, handleTableKey, previewColumnWidth, runTableAction, setColumnWidth, tableLook as tableLookPlugin, tableWidthsOf } from './rich-text-table.js';
|
|
115
116
|
import { TABLE_MENU_EVENT, TableGrips } from './rich-text-table-grips.js';
|
|
@@ -872,6 +873,8 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
872
873
|
}));
|
|
873
874
|
// Headings carry `toggle` (rich-text-toggle-heading.ts).
|
|
874
875
|
ctx.update(headingSchema.key, withToggle);
|
|
876
|
+
// An empty paragraph keeps its `children` (rich-text-empty-paragraph.ts).
|
|
877
|
+
ctx.update(paragraphSchema.key, withEmptyParagraphChildren);
|
|
875
878
|
ctx.update(editorViewOptionsCtx, (options) => ({
|
|
876
879
|
...options,
|
|
877
880
|
editable: () => !latest.current.readOnly,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NodeSchema } from '@milkdown/kit/transformer';
|
|
2
|
+
/**
|
|
3
|
+
* An empty paragraph goes to Markdown with `children: []`. Milkdown's own
|
|
4
|
+
* runner opens and closes the node with nothing in it, and its serializer
|
|
5
|
+
* then leaves `children` out. mdast says a paragraph always has the
|
|
6
|
+
* array, and mdast-util-gfm-task-list-item 2.0.1 reads its length: an
|
|
7
|
+
* empty task item ("- [ ] ", Enter at a list's end) threw there, and the
|
|
8
|
+
* edit was never saved.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withEmptyParagraphChildren<Ctx>(previous: (ctx: Ctx) => NodeSchema): (ctx: Ctx) => NodeSchema;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An empty paragraph goes to Markdown with `children: []`. Milkdown's own
|
|
3
|
+
* runner opens and closes the node with nothing in it, and its serializer
|
|
4
|
+
* then leaves `children` out. mdast says a paragraph always has the
|
|
5
|
+
* array, and mdast-util-gfm-task-list-item 2.0.1 reads its length: an
|
|
6
|
+
* empty task item ("- [ ] ", Enter at a list's end) threw there, and the
|
|
7
|
+
* edit was never saved.
|
|
8
|
+
*/
|
|
9
|
+
export function withEmptyParagraphChildren(previous) {
|
|
10
|
+
return (ctx) => {
|
|
11
|
+
const base = previous(ctx);
|
|
12
|
+
const runner = base.toMarkdown.runner;
|
|
13
|
+
return {
|
|
14
|
+
...base,
|
|
15
|
+
toMarkdown: {
|
|
16
|
+
...base.toMarkdown,
|
|
17
|
+
runner: (state, node) => {
|
|
18
|
+
if (node.content.size === 0)
|
|
19
|
+
state.addNode('paragraph', []);
|
|
20
|
+
else
|
|
21
|
+
runner(state, node);
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'react';
|
|
2
|
-
// Whether the screen is under 48rem (useIsMobile
|
|
2
|
+
// Whether the screen is under 48rem (768px; useIsMobile returns this), read through
|
|
3
3
|
// matchMedia as a store, so rendering on the server or where matchMedia is
|
|
4
4
|
// missing (a test's DOM) gives "not a phone" instead of failing on
|
|
5
5
|
// `window`. DataTable's row list, FilterBar and SecondaryFilters' sheet
|
package/dist/hooks/use-mobile.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { useIsPhone } from "./use-is-phone.js";
|
|
2
|
+
// shadcn's hook (the sidebar, sonner and the package's own code read it),
|
|
3
|
+
// answered by useIsPhone so the 768px breakpoint lives in one place. Same
|
|
4
|
+
// result as shadcn's own `window.innerWidth < 768`, and safe where
|
|
5
|
+
// matchMedia is missing.
|
|
3
6
|
export function useIsMobile() {
|
|
4
|
-
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
7
|
-
const onChange = () => {
|
|
8
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9
|
-
};
|
|
10
|
-
mql.addEventListener("change", onChange);
|
|
11
|
-
return () => mql.removeEventListener("change", onChange);
|
|
12
|
-
}, []);
|
|
13
|
-
return isMobile;
|
|
7
|
+
return useIsPhone();
|
|
14
8
|
}
|
package/dist/testing/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import AxeBuilder from '@axe-core/playwright';
|
|
|
15
15
|
import { expect, test as base } from '@playwright/test';
|
|
16
16
|
import { navPathname, navTargets } from '../components/app/app-shell-nav.js';
|
|
17
17
|
import { PALETTE_STORAGE_KEY, paletteColorScheme } from '../lib/palettes.js';
|
|
18
|
+
import { waitForTransitions } from './transitions.js';
|
|
18
19
|
export { expect };
|
|
19
20
|
// A page load returns at the load event, but the app isn't up yet: React
|
|
20
21
|
// renders only after MSW's worker.start(), which took up to 2.4 s past
|
|
@@ -112,24 +113,6 @@ export function forceLoggedOut(page) {
|
|
|
112
113
|
* they're never read out.
|
|
113
114
|
*/
|
|
114
115
|
export const POPUP_FOCUS_GUARDS = '[data-base-ui-focus-guard]';
|
|
115
|
-
/**
|
|
116
|
-
* Resolves once the page's open and close transitions have finished. A
|
|
117
|
-
* popup fading in is already "visible" to Playwright, and its text is
|
|
118
|
-
* blended with the page behind: axe measured a sheet's muted labels at
|
|
119
|
-
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
120
|
-
* Two frames first, so a transition that starts on the next frame (Base
|
|
121
|
-
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
122
|
-
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
123
|
-
*/
|
|
124
|
-
async function waitForTransitions(page) {
|
|
125
|
-
await page.evaluate(async () => {
|
|
126
|
-
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
127
|
-
const ending = document
|
|
128
|
-
.getAnimations()
|
|
129
|
-
.filter((animation) => animation.effect?.getComputedTiming().endTime !== Infinity);
|
|
130
|
-
await Promise.all(ending.map((animation) => animation.finished.catch(() => undefined)));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
116
|
/**
|
|
134
117
|
* axe on the page as it is now, once its transitions have finished. The
|
|
135
118
|
* options are for a state whose structure a rule doesn't fit, said where
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves once the page's open and close transitions have finished. A
|
|
4
|
+
* popup fading in is already "visible" to Playwright, and its text is
|
|
5
|
+
* blended with the page behind: axe measured a sheet's muted labels at
|
|
6
|
+
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
7
|
+
* Two frames first, so a transition that starts on the next frame (Base
|
|
8
|
+
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
9
|
+
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
10
|
+
*/
|
|
11
|
+
export declare function waitForTransitions(page: Page): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves once the page's open and close transitions have finished. A
|
|
3
|
+
* popup fading in is already "visible" to Playwright, and its text is
|
|
4
|
+
* blended with the page behind: axe measured a sheet's muted labels at
|
|
5
|
+
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
6
|
+
* Two frames first, so a transition that starts on the next frame (Base
|
|
7
|
+
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
8
|
+
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
9
|
+
*/
|
|
10
|
+
export async function waitForTransitions(page) {
|
|
11
|
+
await page.evaluate(async () => {
|
|
12
|
+
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
13
|
+
const ending = document
|
|
14
|
+
.getAnimations()
|
|
15
|
+
.filter((animation) => animation.effect?.getComputedTiming().endTime !== Infinity);
|
|
16
|
+
await Promise.all(ending.map((animation) => animation.finished.catch(() => undefined)));
|
|
17
|
+
});
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.122.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": {
|
|
@@ -137,53 +137,53 @@
|
|
|
137
137
|
},
|
|
138
138
|
"dependencies": {
|
|
139
139
|
"@fontsource-variable/geist": "^5.3.0",
|
|
140
|
-
"@hookform/resolvers": "^5.9.
|
|
141
|
-
"@milkdown/kit": "^7.
|
|
140
|
+
"@hookform/resolvers": "^5.9.2",
|
|
141
|
+
"@milkdown/kit": "^7.23.0",
|
|
142
142
|
"class-variance-authority": "^0.7.1",
|
|
143
|
-
"cn": "^0.3.
|
|
143
|
+
"cn": "^0.3.3",
|
|
144
144
|
"date-fns": "^4.4.0",
|
|
145
|
-
"js-yaml": "^5.
|
|
146
|
-
"lucide-react": "^1.
|
|
147
|
-
"react-day-picker": "^10.0.
|
|
145
|
+
"js-yaml": "^5.5.0",
|
|
146
|
+
"lucide-react": "^1.73.0",
|
|
147
|
+
"react-day-picker": "^10.0.2",
|
|
148
148
|
"react-markdown": "^10.1.0",
|
|
149
149
|
"remark-gfm": "^4.0.1",
|
|
150
150
|
"remark-parse": "^11.0.0",
|
|
151
151
|
"rrule": "2.8.1",
|
|
152
|
-
"shadcn": "^4.
|
|
152
|
+
"shadcn": "^4.23.0",
|
|
153
153
|
"tw-animate-css": "^1.4.0",
|
|
154
154
|
"unified": "^11.0.5"
|
|
155
155
|
},
|
|
156
156
|
"devDependencies": {
|
|
157
|
-
"@axe-core/playwright": "^4.
|
|
158
|
-
"@base-ui/react": "^1.
|
|
157
|
+
"@axe-core/playwright": "^4.14.0",
|
|
158
|
+
"@base-ui/react": "^1.9.0",
|
|
159
159
|
"@eslint/js": "^10.0.1",
|
|
160
|
-
"@playwright/test": "^1.
|
|
161
|
-
"@tailwindcss/vite": "^4.3.
|
|
162
|
-
"@tanstack/eslint-plugin-query": "^5.
|
|
163
|
-
"@tanstack/react-query": "^5.
|
|
164
|
-
"@tanstack/react-table": "^9.
|
|
165
|
-
"@types/node": "^24.
|
|
160
|
+
"@playwright/test": "^1.65.1",
|
|
161
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
162
|
+
"@tanstack/eslint-plugin-query": "^5.107.1",
|
|
163
|
+
"@tanstack/react-query": "^5.107.1",
|
|
164
|
+
"@tanstack/react-table": "^9.3.1",
|
|
165
|
+
"@types/node": "^24.19.2",
|
|
166
166
|
"@types/react": "^19.3.0",
|
|
167
167
|
"@types/react-dom": "^19.3.0",
|
|
168
|
-
"@vitejs/plugin-react": "^6.
|
|
169
|
-
"eslint": "^10.
|
|
168
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
169
|
+
"eslint": "^10.15.0",
|
|
170
170
|
"eslint-plugin-check-file": "^3.3.2",
|
|
171
171
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
172
172
|
"eslint-plugin-react-refresh": "^0.5.7",
|
|
173
|
-
"globals": "^17.
|
|
173
|
+
"globals": "^17.14.0",
|
|
174
174
|
"msw": "^2.15.0",
|
|
175
175
|
"next-themes": "^0.4.6",
|
|
176
176
|
"openapi-typescript": "^7.13.0",
|
|
177
|
-
"react": "^19.3.
|
|
178
|
-
"react-dom": "^19.3.
|
|
179
|
-
"react-hook-form": "^7.
|
|
180
|
-
"react-router": "^7.18.
|
|
177
|
+
"react": "^19.3.1",
|
|
178
|
+
"react-dom": "^19.3.1",
|
|
179
|
+
"react-hook-form": "^7.92.0",
|
|
180
|
+
"react-router": "^7.18.5",
|
|
181
181
|
"sonner": "^2.0.8",
|
|
182
|
-
"tailwindcss": "^4.3.
|
|
182
|
+
"tailwindcss": "^4.3.5",
|
|
183
183
|
"typescript": "~6.0.3",
|
|
184
|
-
"typescript-eslint": "^8.
|
|
185
|
-
"vite": "^8.3.
|
|
186
|
-
"vitest": "^5.0
|
|
184
|
+
"typescript-eslint": "^8.72.2",
|
|
185
|
+
"vite": "^8.3.8",
|
|
186
|
+
"vitest": "^5.1.0",
|
|
187
187
|
"zod": "^4.6.7"
|
|
188
188
|
},
|
|
189
189
|
"publishConfig": {
|