@jsudc/react 0.3.1 → 0.5.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/README.md +1137 -22
- package/dist/actions/RowActionsMenu.d.ts +45 -0
- package/dist/actions/RowActionsMenu.js +161 -0
- package/dist/actions/RowActionsMenu.js.map +1 -0
- package/dist/actions/bulk.d.ts +81 -0
- package/dist/actions/bulk.js +54 -0
- package/dist/actions/bulk.js.map +1 -0
- package/dist/actions/row.d.ts +50 -0
- package/dist/actions/row.js +34 -0
- package/dist/actions/row.js.map +1 -0
- package/dist/actions/useRowActionRunner.d.ts +26 -0
- package/dist/actions/useRowActionRunner.js +198 -0
- package/dist/actions/useRowActionRunner.js.map +1 -0
- package/dist/calendar/CalendarRenderer.js +5 -4
- package/dist/calendar/CalendarRenderer.js.map +1 -1
- package/dist/calendar/EventDetail.js +1 -1
- package/dist/calendar.js +1 -1
- package/dist/cards/CardRenderer.d.ts +8 -1
- package/dist/cards/CardRenderer.js +179 -110
- package/dist/cards/CardRenderer.js.map +1 -1
- package/dist/cells/registry.d.ts +60 -0
- package/dist/cells/registry.js +47 -0
- package/dist/cells/registry.js.map +1 -0
- package/dist/chart/ChartRenderer.js +6 -4
- package/dist/chart/ChartRenderer.js.map +1 -1
- package/dist/chart/ChartWindowControl.js +2 -2
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/dialog.js +4 -3
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu.js +2 -1
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/popover.js +2 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/select.js +2 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/toast.js +3 -2
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/tooltip.js +2 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/data-view/BulkBar.d.ts +36 -0
- package/dist/data-view/BulkBar.js +239 -0
- package/dist/data-view/BulkBar.js.map +1 -0
- package/dist/data-view/FilePreview.js +1 -1
- package/dist/data-view/FilterBuilder.js +2 -2
- package/dist/data-view/FilterChips.js +2 -2
- package/dist/data-view/Freshness.js +1 -1
- package/dist/data-view/LiveIndicator.d.ts +10 -0
- package/dist/data-view/LiveIndicator.js +33 -0
- package/dist/data-view/LiveIndicator.js.map +1 -0
- package/dist/data-view/SearchBox.js +1 -1
- package/dist/data-view/UdcDataView.d.ts +110 -1
- package/dist/data-view/UdcDataView.js +237 -90
- package/dist/data-view/UdcDataView.js.map +1 -1
- package/dist/data-view/useDataViewState.d.ts +8 -0
- package/dist/data-view/useDataViewState.js +2 -1
- package/dist/data-view/useDataViewState.js.map +1 -1
- package/dist/headless.d.ts +9 -0
- package/dist/headless.js +12 -2
- package/dist/i18n/translations.js +136 -0
- package/dist/i18n/translations.js.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.js +17 -4
- package/dist/kanban/KanbanCard.js +1 -1
- package/dist/kanban/KanbanColumn.js +1 -1
- package/dist/kanban/KanbanRenderer.js +6 -5
- package/dist/kanban/KanbanRenderer.js.map +1 -1
- package/dist/lib/scope.d.ts +8 -0
- package/dist/lib/scope.js +12 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lookup/LookupCombobox.js +1 -1
- package/dist/lookup/batch.js +1 -1
- package/dist/lookup/options.js +4 -1
- package/dist/lookup/options.js.map +1 -1
- package/dist/lookup/useUdcLookup.js +9 -3
- package/dist/lookup/useUdcLookup.js.map +1 -1
- package/dist/map/MapRenderer.js +4 -3
- package/dist/map/MapRenderer.js.map +1 -1
- package/dist/renderers/types.d.ts +44 -1
- package/dist/renderers/types.js.map +1 -1
- package/dist/rows/useRowActivation.d.ts +91 -0
- package/dist/rows/useRowActivation.js +257 -0
- package/dist/rows/useRowActivation.js.map +1 -0
- package/dist/rows/useRowSelection.d.ts +92 -0
- package/dist/rows/useRowSelection.js +156 -0
- package/dist/rows/useRowSelection.js.map +1 -0
- package/dist/schema-editor/DeleteFieldDialog.js +2 -2
- package/dist/schema-editor/FieldFormDialog.js +2 -2
- package/dist/schema-editor/TagInput.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.scoped.css +2 -0
- package/dist/table/CellEditor.js +2 -1
- package/dist/table/CellEditor.js.map +1 -1
- package/dist/table/SelectCheckbox.d.ts +15 -0
- package/dist/table/SelectCheckbox.js +37 -0
- package/dist/table/SelectCheckbox.js.map +1 -0
- package/dist/table/TableRenderer.d.ts +15 -1
- package/dist/table/TableRenderer.js +305 -114
- package/dist/table/TableRenderer.js.map +1 -1
- package/dist/table/cells.d.ts +13 -2
- package/dist/table/cells.js +15 -2
- package/dist/table/cells.js.map +1 -1
- package/dist/table/index.d.ts +1 -0
- package/dist/table/states.d.ts +6 -0
- package/dist/table/states.js +14 -1
- package/dist/table/states.js.map +1 -1
- package/dist/table/useRowWindow.d.ts +82 -0
- package/dist/table/useRowWindow.js +182 -0
- package/dist/table/useRowWindow.js.map +1 -0
- package/dist/table.js.map +1 -1
- package/dist/tree/TreeNode.js +1 -1
- package/dist/tree/TreeRenderer.d.ts +2 -0
- package/dist/tree/TreeRenderer.js +16 -10
- package/dist/tree/TreeRenderer.js.map +1 -1
- package/dist/udc/changeFeed.d.ts +94 -0
- package/dist/udc/changeFeed.js +250 -0
- package/dist/udc/changeFeed.js.map +1 -0
- package/dist/udc/changes.d.ts +34 -0
- package/dist/udc/changes.js +79 -0
- package/dist/udc/changes.js.map +1 -0
- package/dist/udc/client.d.ts +15 -1
- package/dist/udc/client.js +34 -10
- package/dist/udc/client.js.map +1 -1
- package/dist/udc/hooks.d.ts +94 -16
- package/dist/udc/hooks.js +113 -10
- package/dist/udc/hooks.js.map +1 -1
- package/dist/udc/keys.d.ts +2 -0
- package/dist/udc/keys.js.map +1 -1
- package/dist/udc/listCache.d.ts +11 -0
- package/dist/udc/listCache.js +38 -0
- package/dist/udc/listCache.js.map +1 -0
- package/dist/udc/provider.d.ts +21 -3
- package/dist/udc/provider.js +23 -2
- package/dist/udc/provider.js.map +1 -1
- package/dist/udc/unauthenticated.d.ts +4 -0
- package/dist/udc/unauthenticated.js +17 -0
- package/dist/udc/unauthenticated.js.map +1 -0
- package/dist/ui-kit/types.d.ts +14 -0
- package/dist/ui-kit/ui.d.ts +1 -0
- package/dist/ui.js +2 -1
- package/dist/url-state/adapters.d.ts +23 -0
- package/dist/url-state/adapters.js +57 -0
- package/dist/url-state/adapters.js.map +1 -0
- package/dist/url-state/index.d.ts +1 -0
- package/package.json +6 -4
package/dist/udc/provider.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { UdcClient } from "@jsudc/core/client";
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { type BulkActionHandlers } from "../actions/bulk.js";
|
|
4
|
+
import { type CellRegistry } from "../cells/registry.js";
|
|
3
5
|
import { type UdcLinks } from "../lookup/links.js";
|
|
4
6
|
import type { RendererRegistry } from "../renderers/types.js";
|
|
5
7
|
import type { UiKit } from "../ui-kit/types.js";
|
|
6
|
-
|
|
8
|
+
import { type UdcChangeFeedOptions } from "./changeFeed.js";
|
|
9
|
+
export { createUdcQueryClient, shouldRetry, type UdcQueryClientOptions, useUdcClient, } from "./client.js";
|
|
7
10
|
/**
|
|
8
11
|
* The root provider: the client, the renderers `UdcDataView` draws its tabs
|
|
9
12
|
* with, and optionally the UI kit they draw with. Without `kit` the kit in
|
|
@@ -11,7 +14,7 @@ export { createUdcQueryClient, shouldRetry, useUdcClient } from "./client.js";
|
|
|
11
14
|
* `renderers` the outer `UdcRenderersProvider`'s registry is kept (else none:
|
|
12
15
|
* every tab says no renderer is registered).
|
|
13
16
|
*/
|
|
14
|
-
export declare function UdcProvider({ client, kit, renderers, links, children, }: {
|
|
17
|
+
export declare function UdcProvider({ client, kit, renderers, links, cells, actions, changes, children, }: {
|
|
15
18
|
client: UdcClient;
|
|
16
19
|
/**
|
|
17
20
|
* Where a lookup link and a `row_link` go: the address of a collection's
|
|
@@ -22,5 +25,20 @@ export declare function UdcProvider({ client, kit, renderers, links, children, }
|
|
|
22
25
|
kit?: UiKit;
|
|
23
26
|
/** `createRendererRegistry(tableRenderer, …)`, or `RENDERERS` from `@jsudc/react/all`. */
|
|
24
27
|
renderers?: RendererRegistry;
|
|
28
|
+
/** `createCellRegistry(...)`: the cell components a column's `render` may name (README "Custom cells"). */
|
|
29
|
+
cells?: CellRegistry;
|
|
30
|
+
/**
|
|
31
|
+
* The default handlers of the bulk actions of every data view below, by
|
|
32
|
+
* `kind` (README "Selection and bulk actions"); a view's `actions` win.
|
|
33
|
+
*/
|
|
34
|
+
actions?: BulkActionHandlers;
|
|
35
|
+
/**
|
|
36
|
+
* The change feed (README "Live updates"): `true`, or options, opens one
|
|
37
|
+
* stream for the collections the views below show, and they refetch when
|
|
38
|
+
* the server says their rows changed instead of on their timer. Off by
|
|
39
|
+
* default: no connection. Left out under another `UdcProvider` with the
|
|
40
|
+
* same client, the outer feed is used.
|
|
41
|
+
*/
|
|
42
|
+
changes?: boolean | UdcChangeFeedOptions;
|
|
25
43
|
children: ReactNode;
|
|
26
44
|
}): import("react").JSX.Element;
|
package/dist/udc/provider.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { UdcActionsProvider } from "../actions/bulk.js";
|
|
2
|
+
import { UdcCellsProvider } from "../cells/registry.js";
|
|
1
3
|
import { UdcLinksProvider } from "../lookup/links.js";
|
|
2
4
|
import { UdcRenderersProvider } from "../renderers/context.js";
|
|
3
5
|
import { UdcUiProvider } from "../ui-kit/context.js";
|
|
6
|
+
import { UdcChangeFeed } from "./changeFeed.js";
|
|
7
|
+
import { UdcChangeFeedContext } from "./changes.js";
|
|
4
8
|
import { UdcClientContext, createUdcQueryClient, shouldRetry, useUdcClient } from "./client.js";
|
|
9
|
+
import { useContext, useEffect, useMemo } from "react";
|
|
5
10
|
import { jsx } from "react/jsx-runtime";
|
|
6
11
|
// src/udc/provider.tsx
|
|
7
12
|
/**
|
|
@@ -11,15 +16,31 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
16
|
* `renderers` the outer `UdcRenderersProvider`'s registry is kept (else none:
|
|
12
17
|
* every tab says no renderer is registered).
|
|
13
18
|
*/
|
|
14
|
-
function UdcProvider({ client, kit, renderers, links, children }) {
|
|
19
|
+
function UdcProvider({ client, kit, renderers, links, cells, actions, changes, children }) {
|
|
20
|
+
const outer = useContext(UdcChangeFeedContext);
|
|
21
|
+
const optionsKey = typeof changes === "object" ? JSON.stringify(changes) : String(changes ?? false);
|
|
22
|
+
const own = useMemo(() => optionsKey === "false" ? null : new UdcChangeFeed(client, optionsKey === "true" ? {} : JSON.parse(optionsKey)), [client, optionsKey]);
|
|
23
|
+
useEffect(() => own ? () => own.close() : void 0, [own]);
|
|
24
|
+
const feed = changes === void 0 ? outer?.client === client ? outer : null : own;
|
|
15
25
|
let inner = /* @__PURE__ */ jsx(UdcClientContext.Provider, {
|
|
16
26
|
value: client,
|
|
17
|
-
children
|
|
27
|
+
children: /* @__PURE__ */ jsx(UdcChangeFeedContext.Provider, {
|
|
28
|
+
value: feed,
|
|
29
|
+
children
|
|
30
|
+
})
|
|
18
31
|
});
|
|
19
32
|
if (links) inner = /* @__PURE__ */ jsx(UdcLinksProvider, {
|
|
20
33
|
links,
|
|
21
34
|
children: inner
|
|
22
35
|
});
|
|
36
|
+
if (cells) inner = /* @__PURE__ */ jsx(UdcCellsProvider, {
|
|
37
|
+
cells,
|
|
38
|
+
children: inner
|
|
39
|
+
});
|
|
40
|
+
if (actions) inner = /* @__PURE__ */ jsx(UdcActionsProvider, {
|
|
41
|
+
actions,
|
|
42
|
+
children: inner
|
|
43
|
+
});
|
|
23
44
|
if (renderers) inner = /* @__PURE__ */ jsx(UdcRenderersProvider, {
|
|
24
45
|
renderers,
|
|
25
46
|
children: inner
|
package/dist/udc/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../../src/udc/provider.tsx"],"sourcesContent":["import type { UdcClient } from \"@jsudc/core/client\";\nimport type
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../../src/udc/provider.tsx"],"sourcesContent":["import type { UdcClient } from \"@jsudc/core/client\";\nimport { type ReactNode, useContext, useEffect, useMemo } from \"react\";\nimport { type BulkActionHandlers, UdcActionsProvider } from \"../actions/bulk.js\";\nimport { type CellRegistry, UdcCellsProvider } from \"../cells/registry.js\";\nimport { type UdcLinks, UdcLinksProvider } from \"../lookup/links.js\";\nimport { UdcRenderersProvider } from \"../renderers/context.js\";\nimport type { RendererRegistry } from \"../renderers/types.js\";\nimport { UdcUiProvider } from \"../ui-kit/context.js\";\nimport type { UiKit } from \"../ui-kit/types.js\";\nimport { UdcChangeFeed, type UdcChangeFeedOptions } from \"./changeFeed.js\";\nimport { UdcChangeFeedContext } from \"./changes.js\";\nimport { UdcClientContext } from \"./client.js\";\n\nexport {\n createUdcQueryClient,\n shouldRetry,\n type UdcQueryClientOptions,\n useUdcClient,\n} from \"./client.js\";\n\n/**\n * The root provider: the client, the renderers `UdcDataView` draws its tabs\n * with, and optionally the UI kit they draw with. Without `kit` the kit in\n * effect is kept (an outer `UdcUiProvider`'s, else `defaultUiKit`); without\n * `renderers` the outer `UdcRenderersProvider`'s registry is kept (else none:\n * every tab says no renderer is registered).\n */\nexport function UdcProvider({\n client,\n kit,\n renderers,\n links,\n cells,\n actions,\n changes,\n children,\n}: {\n client: UdcClient;\n /**\n * Where a lookup link and a `row_link` go: the address of a collection's\n * view, and how to navigate there. Default `defaultUdcLinks` (`/c/<name>`);\n * `UdcReactRouterUrlState collectionPath` sets it for react-router.\n */\n links?: UdcLinks;\n kit?: UiKit;\n /** `createRendererRegistry(tableRenderer, …)`, or `RENDERERS` from `@jsudc/react/all`. */\n renderers?: RendererRegistry;\n /** `createCellRegistry(...)`: the cell components a column's `render` may name (README \"Custom cells\"). */\n cells?: CellRegistry;\n /**\n * The default handlers of the bulk actions of every data view below, by\n * `kind` (README \"Selection and bulk actions\"); a view's `actions` win.\n */\n actions?: BulkActionHandlers;\n /**\n * The change feed (README \"Live updates\"): `true`, or options, opens one\n * stream for the collections the views below show, and they refetch when\n * the server says their rows changed instead of on their timer. Off by\n * default: no connection. Left out under another `UdcProvider` with the\n * same client, the outer feed is used.\n */\n changes?: boolean | UdcChangeFeedOptions;\n children: ReactNode;\n}) {\n const outer = useContext(UdcChangeFeedContext);\n const optionsKey =\n typeof changes === \"object\" ? JSON.stringify(changes) : String(changes ?? false);\n // `changes` is read through its key: a new but equal options object keeps the feed.\n const own = useMemo(\n () =>\n optionsKey === \"false\"\n ? null\n : new UdcChangeFeed(\n client,\n optionsKey === \"true\" ? {} : (JSON.parse(optionsKey) as UdcChangeFeedOptions),\n ),\n [client, optionsKey],\n );\n useEffect(() => (own ? () => own.close() : undefined), [own]);\n const feed = changes === undefined ? (outer?.client === client ? outer : null) : own;\n\n let inner = (\n <UdcClientContext.Provider value={client}>\n <UdcChangeFeedContext.Provider value={feed}>{children}</UdcChangeFeedContext.Provider>\n </UdcClientContext.Provider>\n );\n if (links) inner = <UdcLinksProvider links={links}>{inner}</UdcLinksProvider>;\n if (cells) inner = <UdcCellsProvider cells={cells}>{inner}</UdcCellsProvider>;\n if (actions) inner = <UdcActionsProvider actions={actions}>{inner}</UdcActionsProvider>;\n if (renderers) inner = <UdcRenderersProvider renderers={renderers}>{inner}</UdcRenderersProvider>;\n return kit ? <UdcUiProvider kit={kit}>{inner}</UdcUiProvider> : inner;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BA,SAAgB,YAAY,EAC1B,QACA,KACA,WACA,OACA,OACA,SACA,SACA,YA4BC;CACD,MAAM,QAAQ,WAAW,oBAAoB;CAC7C,MAAM,aACJ,OAAO,YAAY,WAAW,KAAK,UAAU,OAAO,IAAI,OAAO,WAAW,KAAK;CAEjF,MAAM,MAAM,cAER,eAAe,UACX,OACA,IAAI,cACF,QACA,eAAe,SAAS,CAAC,IAAK,KAAK,MAAM,UAAU,CACrD,GACN,CAAC,QAAQ,UAAU,CACrB;CACA,gBAAiB,YAAY,IAAI,MAAM,IAAI,KAAA,GAAY,CAAC,GAAG,CAAC;CAC5D,MAAM,OAAO,YAAY,KAAA,IAAa,OAAO,WAAW,SAAS,QAAQ,OAAQ;CAEjF,IAAI,QACF,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAChC,UAAA,oBAAC,qBAAqB,UAAtB;GAA+B,OAAO;GAAO;EAAwC,CAAA;CAC5D,CAAA;CAE7B,IAAI,OAAO,QAAQ,oBAAC,kBAAD;EAAyB;EAAQ,UAAA;CAAwB,CAAA;CAC5E,IAAI,OAAO,QAAQ,oBAAC,kBAAD;EAAyB;EAAQ,UAAA;CAAwB,CAAA;CAC5E,IAAI,SAAS,QAAQ,oBAAC,oBAAD;EAA6B;EAAU,UAAA;CAA0B,CAAA;CACtF,IAAI,WAAW,QAAQ,oBAAC,sBAAD;EAAiC;EAAY,UAAA;CAA4B,CAAA;CAChG,OAAO,MAAM,oBAAC,eAAD;EAAoB;EAAM,UAAA;CAAqB,CAAA,IAAI;AAClE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
export declare function registerUnauthenticated(qc: QueryClient, notify: (error: unknown) => void): void;
|
|
3
|
+
/** Hand `error` to `qc`'s `onUnauthenticated` (it checks `isUnauthenticated` itself). */
|
|
4
|
+
export declare function notifyUnauthenticated(qc: QueryClient, error: unknown): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/udc/unauthenticated.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `onUnauthenticated` notifier of each query client `createUdcQueryClient`
|
|
4
|
+
* made, so a failure outside TanStack (the change feed) takes the same path as
|
|
5
|
+
* a failed query, burst limiting included. Internal: not exported.
|
|
6
|
+
*/
|
|
7
|
+
var notifiers = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
function registerUnauthenticated(qc, notify) {
|
|
9
|
+
notifiers.set(qc, notify);
|
|
10
|
+
}
|
|
11
|
+
/** Hand `error` to `qc`'s `onUnauthenticated` (it checks `isUnauthenticated` itself). */
|
|
12
|
+
function notifyUnauthenticated(qc, error) {
|
|
13
|
+
notifiers.get(qc)?.(error);
|
|
14
|
+
}
|
|
15
|
+
export { notifyUnauthenticated, registerUnauthenticated };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=unauthenticated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthenticated.js","names":[],"sources":["../../src/udc/unauthenticated.ts"],"sourcesContent":["import type { QueryClient } from \"@tanstack/react-query\";\n\n/**\n * The `onUnauthenticated` notifier of each query client `createUdcQueryClient`\n * made, so a failure outside TanStack (the change feed) takes the same path as\n * a failed query, burst limiting included. Internal: not exported.\n */\nconst notifiers = new WeakMap<QueryClient, (error: unknown) => void>();\n\nexport function registerUnauthenticated(qc: QueryClient, notify: (error: unknown) => void): void {\n notifiers.set(qc, notify);\n}\n\n/** Hand `error` to `qc`'s `onUnauthenticated` (it checks `isUnauthenticated` itself). */\nexport function notifyUnauthenticated(qc: QueryClient, error: unknown): void {\n notifiers.get(qc)?.(error);\n}\n"],"mappings":";;;;;;AAOA,IAAM,4BAAY,IAAI,QAA+C;AAErE,SAAgB,wBAAwB,IAAiB,QAAwC;CAC/F,UAAU,IAAI,IAAI,MAAM;AAC1B;;AAGA,SAAgB,sBAAsB,IAAiB,OAAsB;CAC3E,UAAU,IAAI,EAAE,CAAC,GAAG,KAAK;AAC3B"}
|
package/dist/ui-kit/types.d.ts
CHANGED
|
@@ -129,10 +129,24 @@ export interface UiTriggerProps extends Base {
|
|
|
129
129
|
export interface UiDropdownMenuProps {
|
|
130
130
|
/** `false`: the page behind stays interactive while the menu is open. */
|
|
131
131
|
modal?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Controlled (0.5.0, optional): the menu is open while `true`. A row's
|
|
134
|
+
* actions menu sets it to open from the keyboard and on right-click; a kit
|
|
135
|
+
* that ignores it still opens the menu from its trigger.
|
|
136
|
+
*/
|
|
137
|
+
open?: boolean;
|
|
138
|
+
/** The menu wants to open or close (its trigger, Escape, a click outside, an item chosen). */
|
|
139
|
+
onOpenChange?: (open: boolean) => void;
|
|
132
140
|
children?: ReactNode;
|
|
133
141
|
}
|
|
134
142
|
export interface UiDropdownMenuContentProps extends Base {
|
|
135
143
|
align?: "start" | "center" | "end";
|
|
144
|
+
/**
|
|
145
|
+
* The menu closed and is about to give the focus back to its trigger
|
|
146
|
+
* (0.5.0, optional): `preventDefault()` to put it elsewhere (a row's menu
|
|
147
|
+
* gives it back to the row).
|
|
148
|
+
*/
|
|
149
|
+
onCloseAutoFocus?: (e: PreventableEvent) => void;
|
|
136
150
|
children?: ReactNode;
|
|
137
151
|
}
|
|
138
152
|
export interface UiDropdownMenuItemProps extends Base {
|
package/dist/ui-kit/ui.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { Segmented, type SegmentedOption } from "../components/ui/segmented.js";
|
|
|
9
9
|
export { Select, type SelectOption } from "../components/ui/select.js";
|
|
10
10
|
export { Toaster, type ToastInput, type ToastVariant, useToast } from "../components/ui/toast.js";
|
|
11
11
|
export { Tip, TooltipProvider } from "../components/ui/tooltip.js";
|
|
12
|
+
export { UDC_SCOPE_CLASS } from "../lib/scope.js";
|
|
12
13
|
export { defaultUiKit } from "./default.js";
|
package/dist/ui.js
CHANGED
|
@@ -9,5 +9,6 @@ import { Segmented } from "./components/ui/segmented.js";
|
|
|
9
9
|
import { Select } from "./components/ui/select.js";
|
|
10
10
|
import { Toaster, useToast } from "./components/ui/toast.js";
|
|
11
11
|
import { Tip, TooltipProvider } from "./components/ui/tooltip.js";
|
|
12
|
+
import { UDC_SCOPE_CLASS } from "./lib/scope.js";
|
|
12
13
|
import { defaultUiKit } from "./ui-kit/default.js";
|
|
13
|
-
export { Button, Checkbox, Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Input, Kbd, NativeSelect, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Segmented, Select, Skeleton, Spinner, Tip, Toaster, TooltipProvider, defaultUiKit, inputClass, useToast };
|
|
14
|
+
export { Button, Checkbox, Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Input, Kbd, NativeSelect, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Segmented, Select, Skeleton, Spinner, Tip, Toaster, TooltipProvider, UDC_SCOPE_CLASS, defaultUiKit, inputClass, useToast };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UrlStateAdapter } from "./adapter.js";
|
|
2
|
+
/**
|
|
3
|
+
* `inner`, seen through a key prefix: `get()` returns only the parameters whose
|
|
4
|
+
* name starts with `prefix`, with the prefix taken off, and `set()` rewrites
|
|
5
|
+
* only those, leaving every other parameter of `inner` as it was. A data view
|
|
6
|
+
* under it reads and writes `inbox.q`, `inbox.sort`, `inbox.board`, … while a
|
|
7
|
+
* host's own `?q=` is neither read nor removed, and a second view with another
|
|
8
|
+
* prefix keeps state of its own on the same page. End the prefix with a
|
|
9
|
+
* separator (`inbox.`, `list-`): every key that starts with it is the view's.
|
|
10
|
+
*/
|
|
11
|
+
export declare function prefixUrlStateAdapter(inner: UrlStateAdapter, prefix: string): UrlStateAdapter;
|
|
12
|
+
/** A `UrlStateAdapter` that keeps the query string in memory, plus a way to inspect it. */
|
|
13
|
+
export interface MemoryUrlStateAdapter extends UrlStateAdapter {
|
|
14
|
+
/** Every `set` so far, oldest first: what a push or a replace wrote (for tests and debugging). */
|
|
15
|
+
readonly history: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A query string that lives in memory only: the address bar is never read nor
|
|
19
|
+
* written, and back / forward do not touch it. For a view whose state should
|
|
20
|
+
* not survive a reload or be shared as a link (one pane of a host's screen).
|
|
21
|
+
* Each call is a store of its own; `initial` seeds it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createMemoryUrlStateAdapter(initial?: string | URLSearchParams | Record<string, string>): MemoryUrlStateAdapter;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/url-state/adapters.ts
|
|
2
|
+
/**
|
|
3
|
+
* `inner`, seen through a key prefix: `get()` returns only the parameters whose
|
|
4
|
+
* name starts with `prefix`, with the prefix taken off, and `set()` rewrites
|
|
5
|
+
* only those, leaving every other parameter of `inner` as it was. A data view
|
|
6
|
+
* under it reads and writes `inbox.q`, `inbox.sort`, `inbox.board`, … while a
|
|
7
|
+
* host's own `?q=` is neither read nor removed, and a second view with another
|
|
8
|
+
* prefix keeps state of its own on the same page. End the prefix with a
|
|
9
|
+
* separator (`inbox.`, `list-`): every key that starts with it is the view's.
|
|
10
|
+
*/
|
|
11
|
+
function prefixUrlStateAdapter(inner, prefix) {
|
|
12
|
+
if (!prefix) throw new Error("prefixUrlStateAdapter: the prefix must not be empty");
|
|
13
|
+
const own = (key) => key.startsWith(prefix);
|
|
14
|
+
return {
|
|
15
|
+
get() {
|
|
16
|
+
const out = new URLSearchParams();
|
|
17
|
+
for (const [key, value] of inner.get()) if (own(key)) out.append(key.slice(prefix.length), value);
|
|
18
|
+
return out;
|
|
19
|
+
},
|
|
20
|
+
set(next, opts) {
|
|
21
|
+
const out = new URLSearchParams();
|
|
22
|
+
for (const [key, value] of inner.get()) if (!own(key)) out.append(key, value);
|
|
23
|
+
for (const [key, value] of next) out.append(`${prefix}${key}`, value);
|
|
24
|
+
inner.set(out, opts);
|
|
25
|
+
},
|
|
26
|
+
subscribe: (listener) => inner.subscribe(listener)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A query string that lives in memory only: the address bar is never read nor
|
|
31
|
+
* written, and back / forward do not touch it. For a view whose state should
|
|
32
|
+
* not survive a reload or be shared as a link (one pane of a host's screen).
|
|
33
|
+
* Each call is a store of its own; `initial` seeds it.
|
|
34
|
+
*/
|
|
35
|
+
function createMemoryUrlStateAdapter(initial) {
|
|
36
|
+
let search = new URLSearchParams(initial ?? "").toString();
|
|
37
|
+
const history = [];
|
|
38
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
39
|
+
return {
|
|
40
|
+
get: () => new URLSearchParams(search),
|
|
41
|
+
set(next) {
|
|
42
|
+
search = next.toString();
|
|
43
|
+
history.push(search);
|
|
44
|
+
for (const listener of listeners) listener();
|
|
45
|
+
},
|
|
46
|
+
subscribe(listener) {
|
|
47
|
+
listeners.add(listener);
|
|
48
|
+
return () => {
|
|
49
|
+
listeners.delete(listener);
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
history
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export { createMemoryUrlStateAdapter, prefixUrlStateAdapter };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.js","names":[],"sources":["../../src/url-state/adapters.ts"],"sourcesContent":["import type { UrlStateAdapter } from \"./adapter.js\";\n\n/**\n * `inner`, seen through a key prefix: `get()` returns only the parameters whose\n * name starts with `prefix`, with the prefix taken off, and `set()` rewrites\n * only those, leaving every other parameter of `inner` as it was. A data view\n * under it reads and writes `inbox.q`, `inbox.sort`, `inbox.board`, … while a\n * host's own `?q=` is neither read nor removed, and a second view with another\n * prefix keeps state of its own on the same page. End the prefix with a\n * separator (`inbox.`, `list-`): every key that starts with it is the view's.\n */\nexport function prefixUrlStateAdapter(inner: UrlStateAdapter, prefix: string): UrlStateAdapter {\n if (!prefix) throw new Error(\"prefixUrlStateAdapter: the prefix must not be empty\");\n const own = (key: string) => key.startsWith(prefix);\n return {\n get() {\n const out = new URLSearchParams();\n for (const [key, value] of inner.get()) {\n if (own(key)) out.append(key.slice(prefix.length), value);\n }\n return out;\n },\n set(next, opts) {\n const out = new URLSearchParams();\n for (const [key, value] of inner.get()) if (!own(key)) out.append(key, value);\n for (const [key, value] of next) out.append(`${prefix}${key}`, value);\n inner.set(out, opts);\n },\n subscribe: (listener) => inner.subscribe(listener),\n };\n}\n\n/** A `UrlStateAdapter` that keeps the query string in memory, plus a way to inspect it. */\nexport interface MemoryUrlStateAdapter extends UrlStateAdapter {\n /** Every `set` so far, oldest first: what a push or a replace wrote (for tests and debugging). */\n readonly history: readonly string[];\n}\n\n/**\n * A query string that lives in memory only: the address bar is never read nor\n * written, and back / forward do not touch it. For a view whose state should\n * not survive a reload or be shared as a link (one pane of a host's screen).\n * Each call is a store of its own; `initial` seeds it.\n */\nexport function createMemoryUrlStateAdapter(\n initial?: string | URLSearchParams | Record<string, string>,\n): MemoryUrlStateAdapter {\n let search = new URLSearchParams(initial ?? \"\").toString();\n const history: string[] = [];\n const listeners = new Set<() => void>();\n return {\n get: () => new URLSearchParams(search),\n set(next) {\n search = next.toString();\n history.push(search);\n for (const listener of listeners) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n history,\n };\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,sBAAsB,OAAwB,QAAiC;CAC7F,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,qDAAqD;CAClF,MAAM,OAAO,QAAgB,IAAI,WAAW,MAAM;CAClD,OAAO;EACL,MAAM;GACJ,MAAM,MAAM,IAAI,gBAAgB;GAChC,KAAK,MAAM,CAAC,KAAK,UAAU,MAAM,IAAI,GACnC,IAAI,IAAI,GAAG,GAAG,IAAI,OAAO,IAAI,MAAM,OAAO,MAAM,GAAG,KAAK;GAE1D,OAAO;EACT;EACA,IAAI,MAAM,MAAM;GACd,MAAM,MAAM,IAAI,gBAAgB;GAChC,KAAK,MAAM,CAAC,KAAK,UAAU,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,OAAO,KAAK,KAAK;GAC5E,KAAK,MAAM,CAAC,KAAK,UAAU,MAAM,IAAI,OAAO,GAAG,SAAS,OAAO,KAAK;GACpE,MAAM,IAAI,KAAK,IAAI;EACrB;EACA,YAAY,aAAa,MAAM,UAAU,QAAQ;CACnD;AACF;;;;;;;AAcA,SAAgB,4BACd,SACuB;CACvB,IAAI,SAAS,IAAI,gBAAgB,WAAW,EAAE,CAAC,CAAC,SAAS;CACzD,MAAM,UAAoB,CAAC;CAC3B,MAAM,4BAAY,IAAI,IAAgB;CACtC,OAAO;EACL,WAAW,IAAI,gBAAgB,MAAM;EACrC,IAAI,MAAM;GACR,SAAS,KAAK,SAAS;GACvB,QAAQ,KAAK,MAAM;GACnB,KAAK,MAAM,YAAY,WAAW,SAAS;EAC7C;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;EACA;CACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { type UrlStateAdapter, windowLocationAdapter } from "./adapter.js";
|
|
2
|
+
export { createMemoryUrlStateAdapter, type MemoryUrlStateAdapter, prefixUrlStateAdapter, } from "./adapters.js";
|
|
2
3
|
export { type SetUrlSearchParams, UdcUrlStateProvider, type UdcUrlStateProviderProps, useUrlSearchParams, useUrlStateAdapter, } from "./UrlState.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsudc/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "React components for UDC collections: the data view, its table, cards, kanban, calendar, tree, map and chart renderers (one subpath each), the schema editor, headless hooks and models, i18n, theme and a compiled, udc:-prefixed stylesheet.",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"default": "./dist/react-router.js"
|
|
90
90
|
},
|
|
91
91
|
"./styles.css": "./dist/styles.css",
|
|
92
|
+
"./styles.scoped.css": "./dist/styles.scoped.css",
|
|
92
93
|
"./tokens.css": "./dist/tokens.css",
|
|
93
94
|
"./package.json": "./package.json"
|
|
94
95
|
},
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
},
|
|
103
104
|
"scripts": {
|
|
104
105
|
"build": "vite build && tsc -p tsconfig.build.json && npm run build:css",
|
|
105
|
-
"build:css": "tailwindcss -i src/styles.css -o dist/styles.css --minify && node -e \"require('node:fs').copyFileSync('src/tokens.css', 'dist/tokens.css')\" && node scripts/check-css.mjs && node scripts/check-classes.mjs",
|
|
106
|
+
"build:css": "tailwindcss -i src/styles.css -o dist/styles.css --minify && node -e \"require('node:fs').copyFileSync('src/tokens.css', 'dist/tokens.css')\" && node scripts/check-css.mjs && node scripts/check-classes.mjs && tailwindcss -i src/styles.scoped.css -o dist/styles.scoped.css && node scripts/scope-css.mjs dist/styles.scoped.css && node scripts/check-scoped-css.mjs",
|
|
106
107
|
"prepare": "npm run build",
|
|
107
108
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
108
109
|
"check:types": "tsc -p smoke/tsconfig.nodenext.json && tsc -p smoke/tsconfig.bundler.json",
|
|
@@ -119,7 +120,7 @@
|
|
|
119
120
|
"@dnd-kit/core": "^6.3.1",
|
|
120
121
|
"@dnd-kit/sortable": "^10.0.0",
|
|
121
122
|
"@dnd-kit/utilities": "^3.2.2",
|
|
122
|
-
"@jsudc/core": "^0.
|
|
123
|
+
"@jsudc/core": "^0.5.0",
|
|
123
124
|
"@tanstack/react-query": "^5.104.4",
|
|
124
125
|
"@tanstack/react-table": "^8.21.3",
|
|
125
126
|
"leaflet": "^1.9.4",
|
|
@@ -158,7 +159,7 @@
|
|
|
158
159
|
"@dnd-kit/core": "^6.3.1",
|
|
159
160
|
"@dnd-kit/sortable": "^10.0.0",
|
|
160
161
|
"@dnd-kit/utilities": "^3.2.2",
|
|
161
|
-
"@jsudc/core": "^0.
|
|
162
|
+
"@jsudc/core": "^0.5.0",
|
|
162
163
|
"@tailwindcss/cli": "^4.3.3",
|
|
163
164
|
"@tanstack/react-query": "^5.104.4",
|
|
164
165
|
"@tanstack/react-table": "^8.21.3",
|
|
@@ -173,6 +174,7 @@
|
|
|
173
174
|
"@vitejs/plugin-react": "^6.1.2",
|
|
174
175
|
"jsdom": "^30.1.3",
|
|
175
176
|
"leaflet": "^1.9.4",
|
|
177
|
+
"lightningcss": "^1.33.0",
|
|
176
178
|
"lucide-react": "^1.59.0",
|
|
177
179
|
"radix-ui": "^1.8.1",
|
|
178
180
|
"react": "^19.3.1",
|