@cratis/scene.components 3.3.0 → 3.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/cratisComponentsPackage.ts +1 -1
- package/data/SceneDataTable.tsx +11 -1
- package/data/for_SceneDataTable/when_forwarding_query_arguments.tsx +102 -0
- package/dist/cjs/cratisComponentsPackage.js +1 -1
- package/dist/cjs/cratisComponentsPackage.js.map +1 -1
- package/dist/cjs/data/SceneDataTable.js +14 -0
- package/dist/cjs/data/SceneDataTable.js.map +1 -1
- package/dist/esm/cratisComponentsPackage.js +1 -1
- package/dist/esm/cratisComponentsPackage.js.map +1 -1
- package/dist/esm/data/SceneDataTable.d.ts.map +1 -1
- package/dist/esm/data/SceneDataTable.js +15 -1
- package/dist/esm/data/SceneDataTable.js.map +1 -1
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.d.ts +2 -0
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.d.ts.map +1 -0
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js +90 -0
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js.map +1 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_arguments.d.ts +2 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_arguments.d.ts.map +1 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_arguments.js +11 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_arguments.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/for_cratisComponentsPackage/when_describing_query_arguments.ts +15 -0
- package/package.json +8 -8
|
@@ -88,7 +88,7 @@ export const cratisComponentsPackageManifest: ScenePackage = {
|
|
|
88
88
|
themes: [],
|
|
89
89
|
|
|
90
90
|
displayName: 'Cratis Components',
|
|
91
|
-
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind.",
|
|
91
|
+
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries.",
|
|
92
92
|
module: '@cratis/scene.components',
|
|
93
93
|
license: 'MIT',
|
|
94
94
|
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',
|
package/data/SceneDataTable.tsx
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { lazy } from 'react';
|
|
5
5
|
import { RegisteredComponentProps } from '@cratis/scene.react';
|
|
6
6
|
import { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';
|
|
7
|
-
import { stringArrayProperty, stringProperty } from '../properties';
|
|
7
|
+
import { objectProperty, stringArrayProperty, stringProperty } from '../properties';
|
|
8
|
+
import { Placeholder } from '../bindings/Placeholder';
|
|
8
9
|
|
|
9
10
|
const DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/components/DataTables')).DataTableForQuery }));
|
|
10
11
|
|
|
@@ -19,6 +20,9 @@ const DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/co
|
|
|
19
20
|
* back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.
|
|
20
21
|
*
|
|
21
22
|
* The `query` property names an Arc query proxy; the columns come from the `content` slot.
|
|
23
|
+
* Optional `queryArguments` is an explicit object forwarded unchanged to that proxy. Invalid values
|
|
24
|
+
* render a placeholder rather than accidentally executing a query without its arguments. This remains
|
|
25
|
+
* a collection table; forwarding arguments does not make optional single-result queries compatible.
|
|
22
26
|
*
|
|
23
27
|
* There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop
|
|
24
28
|
* so existing call sites compile, but it no longer does anything - filtering is always applied to the
|
|
@@ -30,10 +34,16 @@ export function SceneDataTable({ element, slots }: RegisteredComponentProps) {
|
|
|
30
34
|
const { name, target } = resolveElementBinding(element, BindingKind.Query);
|
|
31
35
|
if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;
|
|
32
36
|
|
|
37
|
+
const queryArguments = objectProperty(element.properties, 'queryArguments');
|
|
38
|
+
if (element.properties.queryArguments !== undefined && queryArguments === undefined) {
|
|
39
|
+
return <Placeholder element={element} problem='Invalid queryArguments: expected an object' />;
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
return (
|
|
34
43
|
<ArcRuntimeBoundary>
|
|
35
44
|
<DataTableForQuery
|
|
36
45
|
query={target}
|
|
46
|
+
{...(queryArguments === undefined ? {} : { queryArguments })}
|
|
37
47
|
emptyMessage={stringProperty(element.properties, 'emptyMessage') ?? ''}
|
|
38
48
|
dataKey={stringProperty(element.properties, 'dataKey')}
|
|
39
49
|
globalFilterFields={stringArrayProperty(element.properties, 'globalFilterFields')}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { act, cleanup, render, screen } from '@testing-library/react';
|
|
5
|
+
import { vi } from 'vitest';
|
|
6
|
+
import { externalComponent } from '../../given';
|
|
7
|
+
|
|
8
|
+
class InvoicesForProject {}
|
|
9
|
+
class AnotherQuery {}
|
|
10
|
+
|
|
11
|
+
// Load a fresh adapter so its lazy component cannot leak the peer double into other specs.
|
|
12
|
+
describe('when forwarding query arguments', () => {
|
|
13
|
+
const suppliedId = 'project-with-an-explicit-id';
|
|
14
|
+
const received = vi.fn<(properties: Record<string, unknown>) => void>();
|
|
15
|
+
let SceneDataTable: typeof import('../SceneDataTable').SceneDataTable;
|
|
16
|
+
let bindings: typeof import('../../bindings');
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
vi.resetModules();
|
|
20
|
+
received.mockClear();
|
|
21
|
+
vi.doMock('@cratis/components/DataTables', () => ({
|
|
22
|
+
DataTableForQuery: (properties: Record<string, unknown>) => {
|
|
23
|
+
received(properties);
|
|
24
|
+
return <div data-testid='query-table' />;
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
bindings = await import('../../bindings');
|
|
28
|
+
bindings.clearBindings();
|
|
29
|
+
bindings.registerQuery('InvoicesForProject', InvoicesForProject);
|
|
30
|
+
bindings.registerQuery('AnotherQuery', AnotherQuery);
|
|
31
|
+
({ SceneDataTable } = await import('../SceneDataTable'));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
cleanup();
|
|
36
|
+
bindings.clearBindings();
|
|
37
|
+
vi.doUnmock('@cratis/components/DataTables');
|
|
38
|
+
vi.resetModules();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
async function renderTable(properties: Record<string, unknown>) {
|
|
42
|
+
const element = externalComponent('Cratis.Components:dataTable', properties);
|
|
43
|
+
await act(async () => {
|
|
44
|
+
render(<SceneDataTable element={element} slots={{}} />);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
it('should pass the exact registered constructor and explicit projectId object through the runtime boundary', async () => {
|
|
49
|
+
const queryArguments = { projectId: suppliedId };
|
|
50
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
51
|
+
await screen.findByTestId('query-table');
|
|
52
|
+
const properties = received.mock.lastCall![0];
|
|
53
|
+
(properties.query === InvoicesForProject).should.equal(true);
|
|
54
|
+
(properties.queryArguments === queryArguments).should.equal(true);
|
|
55
|
+
properties.should.have.property('queryArguments').that.deep.equals({ projectId: suppliedId });
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should preserve all supplied keys and values without normalization or defaults', async () => {
|
|
59
|
+
const queryArguments = { projectId: suppliedId, ProjectID: 'distinct', limit: 0, enabled: false, optional: null, filter: { names: ['one'] } };
|
|
60
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
61
|
+
await screen.findByTestId('query-table');
|
|
62
|
+
(received.mock.lastCall![0].queryArguments === queryArguments).should.equal(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should leave omitted arguments absent from the underlying component props', async () => {
|
|
66
|
+
await renderTable({ query: 'InvoicesForProject' });
|
|
67
|
+
await screen.findByTestId('query-table');
|
|
68
|
+
Object.prototype.hasOwnProperty.call(received.mock.lastCall![0], 'queryArguments').should.equal(false);
|
|
69
|
+
(received.mock.lastCall![0].query === InvoicesForProject).should.equal(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should treat undefined arguments as omitted like the existing property readers', async () => {
|
|
73
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments: undefined });
|
|
74
|
+
await screen.findByTestId('query-table');
|
|
75
|
+
Object.prototype.hasOwnProperty.call(received.mock.lastCall![0], 'queryArguments').should.equal(false);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should pass an explicitly empty argument object unchanged', async () => {
|
|
79
|
+
const queryArguments = {};
|
|
80
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
81
|
+
await screen.findByTestId('query-table');
|
|
82
|
+
(received.mock.lastCall![0].queryArguments === queryArguments).should.equal(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
for (const queryArguments of [[], ['project'], 'project', '{"projectId":"project"}', 42, false, null]) {
|
|
86
|
+
it(`should visibly reject ${JSON.stringify(queryArguments)} without mounting a query table`, async () => {
|
|
87
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
88
|
+
(screen.getByText("Invalid queryArguments: expected an object on Cratis.Components:dataTable") !== null).should.equal(true);
|
|
89
|
+
received.mock.calls.should.have.lengthOf(0);
|
|
90
|
+
(screen.queryByTestId('query-table') === null).should.equal(true);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const queryArguments of [{ projectId: suppliedId }, null, []]) {
|
|
95
|
+
it(`should retain MissingBinding precedence and never choose another registered query with ${JSON.stringify(queryArguments)}`, async () => {
|
|
96
|
+
await renderTable({ query: 'UnregisteredQuery', queryArguments });
|
|
97
|
+
(screen.getByText("Unresolved query binding 'UnregisteredQuery' on Cratis.Components:dataTable") !== null).should.equal(true);
|
|
98
|
+
received.mock.calls.should.have.lengthOf(0);
|
|
99
|
+
(screen.queryByText(/Invalid queryArguments/) === null).should.equal(true);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
@@ -90,7 +90,7 @@ var cratisComponents = require('./cratisComponents.js');
|
|
|
90
90
|
// Shipping a theme here would be this library asserting a look it was specifically built not to have.
|
|
91
91
|
themes: [],
|
|
92
92
|
displayName: 'Cratis Components',
|
|
93
|
-
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind.",
|
|
93
|
+
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries.",
|
|
94
94
|
module: '@cratis/scene.components',
|
|
95
95
|
license: 'MIT',
|
|
96
96
|
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,4CAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,
|
|
1
|
+
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,4CAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,gLAAA;IACbC,MAAAA,EAAQ,0BAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;;;;;UAOaC,uBAAAA,GAA8C;IACvDC,QAAAA,EAAUpB,+BAAAA;IACVS,UAAAA,EAAYY;AAChB;;;"}
|
|
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var BindingKind = require('../bindings/BindingKind.js');
|
|
6
6
|
var resolveElementBinding = require('../bindings/resolveElementBinding.js');
|
|
7
|
+
var Placeholder = require('../bindings/Placeholder.js');
|
|
7
8
|
var MissingBinding = require('../bindings/MissingBinding.js');
|
|
8
9
|
var ArcRuntimeBoundary = require('../bindings/ArcRuntimeBoundary.js');
|
|
9
10
|
var properties = require('../properties.js');
|
|
@@ -22,6 +23,9 @@ const DataTableForQuery = /*#__PURE__*/ react.lazy(async ()=>({
|
|
|
22
23
|
* back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.
|
|
23
24
|
*
|
|
24
25
|
* The `query` property names an Arc query proxy; the columns come from the `content` slot.
|
|
26
|
+
* Optional `queryArguments` is an explicit object forwarded unchanged to that proxy. Invalid values
|
|
27
|
+
* render a placeholder rather than accidentally executing a query without its arguments. This remains
|
|
28
|
+
* a collection table; forwarding arguments does not make optional single-result queries compatible.
|
|
25
29
|
*
|
|
26
30
|
* There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop
|
|
27
31
|
* so existing call sites compile, but it no longer does anything - filtering is always applied to the
|
|
@@ -35,9 +39,19 @@ const DataTableForQuery = /*#__PURE__*/ react.lazy(async ()=>({
|
|
|
35
39
|
kind: BindingKind.BindingKind.Query,
|
|
36
40
|
name: name
|
|
37
41
|
});
|
|
42
|
+
const queryArguments = properties.objectProperty(element.properties, 'queryArguments');
|
|
43
|
+
if (element.properties.queryArguments !== undefined && queryArguments === undefined) {
|
|
44
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Placeholder.Placeholder, {
|
|
45
|
+
element: element,
|
|
46
|
+
problem: "Invalid queryArguments: expected an object"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
38
49
|
return /*#__PURE__*/ jsxRuntime.jsx(ArcRuntimeBoundary.ArcRuntimeBoundary, {
|
|
39
50
|
children: /*#__PURE__*/ jsxRuntime.jsx(DataTableForQuery, {
|
|
40
51
|
query: target,
|
|
52
|
+
...queryArguments === undefined ? {} : {
|
|
53
|
+
queryArguments
|
|
54
|
+
},
|
|
41
55
|
emptyMessage: properties.stringProperty(element.properties, 'emptyMessage') ?? '',
|
|
42
56
|
dataKey: properties.stringProperty(element.properties, 'dataKey'),
|
|
43
57
|
globalFilterFields: properties.stringArrayProperty(element.properties, 'globalFilterFields'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneDataTable.js","sources":["../../../data/SceneDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport { stringArrayProperty, stringProperty } from '../properties';\n\nconst DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/components/DataTables')).DataTableForQuery }));\n\n/**\n * The `Cratis.Components:dataTable` component, also registered as `table` - `DataTableForQuery` from\n * `@cratis/components/DataTables`.\n *\n * Registering it under the bare name `table` as well is override priority working as designed: a profile\n * listing `core`, `PrimeReact` and `Cratis.Components` in that order resolves `table` here and records\n * the other two as shadowed. That is the right outcome, because this is a strictly better `table` for a\n * Cratis application - it performs the query, pages against the server, and wires filtering and sorting\n * back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.\n *\n * The `query` property names an Arc query proxy; the columns come from the `content` slot.\n *\n * There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop\n * so existing call sites compile, but it no longer does anything - filtering is always applied to the\n * loaded page. Exposing a screen property that reads as a choice and silently is not would be worse than\n * not offering it, so a screen that set it now gets a property-not-recognized signal rather than a\n * setting that quietly stopped mattering.\n */\nexport function SceneDataTable({ element, slots }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Query);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;\n\n return (\n <ArcRuntimeBoundary>\n <DataTableForQuery\n query={target}\n emptyMessage={stringProperty(element.properties, 'emptyMessage') ?? ''}\n dataKey={stringProperty(element.properties, 'dataKey')}\n globalFilterFields={stringArrayProperty(element.properties, 'globalFilterFields')}\n className={stringProperty(element.properties, 'className')}\n >\n {slots.content}\n </DataTableForQuery>\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["DataTableForQuery","lazy","default","SceneDataTable","element","slots","name","target","resolveElementBinding","BindingKind","Query","_jsx","MissingBinding","kind","ArcRuntimeBoundary","query","emptyMessage","stringProperty","
|
|
1
|
+
{"version":3,"file":"SceneDataTable.js","sources":["../../../data/SceneDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport { objectProperty, stringArrayProperty, stringProperty } from '../properties';\nimport { Placeholder } from '../bindings/Placeholder';\n\nconst DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/components/DataTables')).DataTableForQuery }));\n\n/**\n * The `Cratis.Components:dataTable` component, also registered as `table` - `DataTableForQuery` from\n * `@cratis/components/DataTables`.\n *\n * Registering it under the bare name `table` as well is override priority working as designed: a profile\n * listing `core`, `PrimeReact` and `Cratis.Components` in that order resolves `table` here and records\n * the other two as shadowed. That is the right outcome, because this is a strictly better `table` for a\n * Cratis application - it performs the query, pages against the server, and wires filtering and sorting\n * back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.\n *\n * The `query` property names an Arc query proxy; the columns come from the `content` slot.\n * Optional `queryArguments` is an explicit object forwarded unchanged to that proxy. Invalid values\n * render a placeholder rather than accidentally executing a query without its arguments. This remains\n * a collection table; forwarding arguments does not make optional single-result queries compatible.\n *\n * There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop\n * so existing call sites compile, but it no longer does anything - filtering is always applied to the\n * loaded page. Exposing a screen property that reads as a choice and silently is not would be worse than\n * not offering it, so a screen that set it now gets a property-not-recognized signal rather than a\n * setting that quietly stopped mattering.\n */\nexport function SceneDataTable({ element, slots }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Query);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;\n\n const queryArguments = objectProperty(element.properties, 'queryArguments');\n if (element.properties.queryArguments !== undefined && queryArguments === undefined) {\n return <Placeholder element={element} problem='Invalid queryArguments: expected an object' />;\n }\n\n return (\n <ArcRuntimeBoundary>\n <DataTableForQuery\n query={target}\n {...(queryArguments === undefined ? {} : { queryArguments })}\n emptyMessage={stringProperty(element.properties, 'emptyMessage') ?? ''}\n dataKey={stringProperty(element.properties, 'dataKey')}\n globalFilterFields={stringArrayProperty(element.properties, 'globalFilterFields')}\n className={stringProperty(element.properties, 'className')}\n >\n {slots.content}\n </DataTableForQuery>\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["DataTableForQuery","lazy","default","SceneDataTable","element","slots","name","target","resolveElementBinding","BindingKind","Query","_jsx","MissingBinding","kind","queryArguments","objectProperty","properties","undefined","Placeholder","problem","ArcRuntimeBoundary","query","emptyMessage","stringProperty","dataKey","globalFilterFields","stringArrayProperty","className","content"],"mappings":";;;;;;;;;;;AASA,MAAMA,iBAAAA,iBAAoBC,UAAAA,CAAK,WAAa;AAAEC,QAAAA,OAAAA,EAAS,CAAC,MAAM,OAAO,+BAAA,CAA+B,EAAGF;KAAkB,CAAA,CAAA;AAEzH;;;;;;;;;;;;;;;;;;;;AAoBC,IACM,SAASG,cAAAA,CAAe,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;IACvE,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGC,2CAAAA,CAAsBJ,OAAAA,EAASK,uBAAAA,CAAYC,KAAK,CAAA;IACzE,IAAI,CAACH,MAAAA,EAAQ,qBAAOI,cAAA,CAACC,6BAAAA,EAAAA;QAAeR,OAAAA,EAASA,OAAAA;AAASS,QAAAA,IAAAA,EAAMJ,wBAAYC,KAAK;QAAEJ,IAAAA,EAAMA;;AAErF,IAAA,MAAMQ,cAAAA,GAAiBC,yBAAAA,CAAeX,OAAAA,CAAQY,UAAU,EAAE,gBAAA,CAAA;AAC1D,IAAA,IAAIZ,QAAQY,UAAU,CAACF,cAAc,KAAKG,SAAAA,IAAaH,mBAAmBG,SAAAA,EAAW;AACjF,QAAA,qBAAON,cAAA,CAACO,uBAAAA,EAAAA;YAAYd,OAAAA,EAASA,OAAAA;YAASe,OAAAA,EAAQ;;AAClD,IAAA;AAEA,IAAA,qBACIR,cAAA,CAACS,qCAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAT,cAAA,CAACX,iBAAAA,EAAAA;YACGqB,KAAAA,EAAOd,MAAAA;YACN,GAAIO,cAAAA,KAAmBG,SAAAA,GAAY,EAAC,GAAI;AAAEH,gBAAAA;aAAgB;AAC3DQ,YAAAA,YAAAA,EAAcC,yBAAAA,CAAenB,OAAAA,CAAQY,UAAU,EAAE,cAAA,CAAA,IAAmB,EAAA;YACpEQ,OAAAA,EAASD,yBAAAA,CAAenB,OAAAA,CAAQY,UAAU,EAAE,SAAA,CAAA;YAC5CS,kBAAAA,EAAoBC,8BAAAA,CAAoBtB,OAAAA,CAAQY,UAAU,EAAE,oBAAA,CAAA;YAC5DW,SAAAA,EAAWJ,yBAAAA,CAAenB,OAAAA,CAAQY,UAAU,EAAE,WAAA,CAAA;AAE7CX,YAAAA,QAAAA,EAAAA,KAAAA,CAAMuB;;;AAIvB;;"}
|
|
@@ -88,7 +88,7 @@ import { cratisComponents, cratisComponentsPackageName } from './cratisComponent
|
|
|
88
88
|
// Shipping a theme here would be this library asserting a look it was specifically built not to have.
|
|
89
89
|
themes: [],
|
|
90
90
|
displayName: 'Cratis Components',
|
|
91
|
-
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind.",
|
|
91
|
+
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries.",
|
|
92
92
|
module: '@cratis/scene.components',
|
|
93
93
|
license: 'MIT',
|
|
94
94
|
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,2BAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,YAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,
|
|
1
|
+
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,2BAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,YAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,gLAAA;IACbC,MAAAA,EAAQ,0BAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;;;;;UAOaC,uBAAAA,GAA8C;IACvDC,QAAAA,EAAUpB,+BAAAA;IACVS,UAAAA,EAAYY;AAChB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneDataTable.d.ts","sourceRoot":"","sources":["../../../data/SceneDataTable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SceneDataTable.d.ts","sourceRoot":"","sources":["../../../data/SceneDataTable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AA4B/D,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAuB1E"}
|
|
@@ -2,9 +2,10 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { lazy } from 'react';
|
|
3
3
|
import { BindingKind } from '../bindings/BindingKind.js';
|
|
4
4
|
import { resolveElementBinding } from '../bindings/resolveElementBinding.js';
|
|
5
|
+
import { Placeholder } from '../bindings/Placeholder.js';
|
|
5
6
|
import { MissingBinding } from '../bindings/MissingBinding.js';
|
|
6
7
|
import { ArcRuntimeBoundary } from '../bindings/ArcRuntimeBoundary.js';
|
|
7
|
-
import { stringProperty, stringArrayProperty } from '../properties.js';
|
|
8
|
+
import { objectProperty, stringProperty, stringArrayProperty } from '../properties.js';
|
|
8
9
|
|
|
9
10
|
const DataTableForQuery = /*#__PURE__*/ lazy(async ()=>({
|
|
10
11
|
default: (await import('@cratis/components/DataTables')).DataTableForQuery
|
|
@@ -20,6 +21,9 @@ const DataTableForQuery = /*#__PURE__*/ lazy(async ()=>({
|
|
|
20
21
|
* back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.
|
|
21
22
|
*
|
|
22
23
|
* The `query` property names an Arc query proxy; the columns come from the `content` slot.
|
|
24
|
+
* Optional `queryArguments` is an explicit object forwarded unchanged to that proxy. Invalid values
|
|
25
|
+
* render a placeholder rather than accidentally executing a query without its arguments. This remains
|
|
26
|
+
* a collection table; forwarding arguments does not make optional single-result queries compatible.
|
|
23
27
|
*
|
|
24
28
|
* There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop
|
|
25
29
|
* so existing call sites compile, but it no longer does anything - filtering is always applied to the
|
|
@@ -33,9 +37,19 @@ const DataTableForQuery = /*#__PURE__*/ lazy(async ()=>({
|
|
|
33
37
|
kind: BindingKind.Query,
|
|
34
38
|
name: name
|
|
35
39
|
});
|
|
40
|
+
const queryArguments = objectProperty(element.properties, 'queryArguments');
|
|
41
|
+
if (element.properties.queryArguments !== undefined && queryArguments === undefined) {
|
|
42
|
+
return /*#__PURE__*/ jsx(Placeholder, {
|
|
43
|
+
element: element,
|
|
44
|
+
problem: "Invalid queryArguments: expected an object"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
36
47
|
return /*#__PURE__*/ jsx(ArcRuntimeBoundary, {
|
|
37
48
|
children: /*#__PURE__*/ jsx(DataTableForQuery, {
|
|
38
49
|
query: target,
|
|
50
|
+
...queryArguments === undefined ? {} : {
|
|
51
|
+
queryArguments
|
|
52
|
+
},
|
|
39
53
|
emptyMessage: stringProperty(element.properties, 'emptyMessage') ?? '',
|
|
40
54
|
dataKey: stringProperty(element.properties, 'dataKey'),
|
|
41
55
|
globalFilterFields: stringArrayProperty(element.properties, 'globalFilterFields'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneDataTable.js","sources":["../../../data/SceneDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport { stringArrayProperty, stringProperty } from '../properties';\n\nconst DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/components/DataTables')).DataTableForQuery }));\n\n/**\n * The `Cratis.Components:dataTable` component, also registered as `table` - `DataTableForQuery` from\n * `@cratis/components/DataTables`.\n *\n * Registering it under the bare name `table` as well is override priority working as designed: a profile\n * listing `core`, `PrimeReact` and `Cratis.Components` in that order resolves `table` here and records\n * the other two as shadowed. That is the right outcome, because this is a strictly better `table` for a\n * Cratis application - it performs the query, pages against the server, and wires filtering and sorting\n * back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.\n *\n * The `query` property names an Arc query proxy; the columns come from the `content` slot.\n *\n * There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop\n * so existing call sites compile, but it no longer does anything - filtering is always applied to the\n * loaded page. Exposing a screen property that reads as a choice and silently is not would be worse than\n * not offering it, so a screen that set it now gets a property-not-recognized signal rather than a\n * setting that quietly stopped mattering.\n */\nexport function SceneDataTable({ element, slots }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Query);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;\n\n return (\n <ArcRuntimeBoundary>\n <DataTableForQuery\n query={target}\n emptyMessage={stringProperty(element.properties, 'emptyMessage') ?? ''}\n dataKey={stringProperty(element.properties, 'dataKey')}\n globalFilterFields={stringArrayProperty(element.properties, 'globalFilterFields')}\n className={stringProperty(element.properties, 'className')}\n >\n {slots.content}\n </DataTableForQuery>\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["DataTableForQuery","lazy","default","SceneDataTable","element","slots","name","target","resolveElementBinding","BindingKind","Query","_jsx","MissingBinding","kind","ArcRuntimeBoundary","query","emptyMessage","stringProperty","
|
|
1
|
+
{"version":3,"file":"SceneDataTable.js","sources":["../../../data/SceneDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport { objectProperty, stringArrayProperty, stringProperty } from '../properties';\nimport { Placeholder } from '../bindings/Placeholder';\n\nconst DataTableForQuery = lazy(async () => ({ default: (await import('@cratis/components/DataTables')).DataTableForQuery }));\n\n/**\n * The `Cratis.Components:dataTable` component, also registered as `table` - `DataTableForQuery` from\n * `@cratis/components/DataTables`.\n *\n * Registering it under the bare name `table` as well is override priority working as designed: a profile\n * listing `core`, `PrimeReact` and `Cratis.Components` in that order resolves `table` here and records\n * the other two as shadowed. That is the right outcome, because this is a strictly better `table` for a\n * Cratis application - it performs the query, pages against the server, and wires filtering and sorting\n * back into it, where PrimeReact's `DataTable` is handed rows and knows nothing about where they came from.\n *\n * The `query` property names an Arc query proxy; the columns come from the `content` slot.\n * Optional `queryArguments` is an explicit object forwarded unchanged to that proxy. Invalid values\n * render a placeholder rather than accidentally executing a query without its arguments. This remains\n * a collection table; forwarding arguments does not make optional single-result queries compatible.\n *\n * There is deliberately no `clientFiltering` property. `@cratis/components` 3.0.0 still accepts the prop\n * so existing call sites compile, but it no longer does anything - filtering is always applied to the\n * loaded page. Exposing a screen property that reads as a choice and silently is not would be worse than\n * not offering it, so a screen that set it now gets a property-not-recognized signal rather than a\n * setting that quietly stopped mattering.\n */\nexport function SceneDataTable({ element, slots }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Query);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;\n\n const queryArguments = objectProperty(element.properties, 'queryArguments');\n if (element.properties.queryArguments !== undefined && queryArguments === undefined) {\n return <Placeholder element={element} problem='Invalid queryArguments: expected an object' />;\n }\n\n return (\n <ArcRuntimeBoundary>\n <DataTableForQuery\n query={target}\n {...(queryArguments === undefined ? {} : { queryArguments })}\n emptyMessage={stringProperty(element.properties, 'emptyMessage') ?? ''}\n dataKey={stringProperty(element.properties, 'dataKey')}\n globalFilterFields={stringArrayProperty(element.properties, 'globalFilterFields')}\n className={stringProperty(element.properties, 'className')}\n >\n {slots.content}\n </DataTableForQuery>\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["DataTableForQuery","lazy","default","SceneDataTable","element","slots","name","target","resolveElementBinding","BindingKind","Query","_jsx","MissingBinding","kind","queryArguments","objectProperty","properties","undefined","Placeholder","problem","ArcRuntimeBoundary","query","emptyMessage","stringProperty","dataKey","globalFilterFields","stringArrayProperty","className","content"],"mappings":";;;;;;;;;AASA,MAAMA,iBAAAA,iBA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YAC5DW,SAAAA,EAAWJ,cAAAA,CAAenB,OAAAA,CAAQY,UAAU,EAAE,WAAA,CAAA;AAE7CX,YAAAA,QAAAA,EAAAA,KAAAA,CAAMuB;;;AAIvB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_forwarding_query_arguments.d.ts","sourceRoot":"","sources":["../../../../data/for_SceneDataTable/when_forwarding_query_arguments.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { act, cleanup, render, screen } from '@testing-library/react';
|
|
3
|
+
import { vi } from 'vitest';
|
|
4
|
+
import { externalComponent } from '../../given';
|
|
5
|
+
class InvoicesForProject {
|
|
6
|
+
}
|
|
7
|
+
class AnotherQuery {
|
|
8
|
+
}
|
|
9
|
+
describe('when forwarding query arguments', () => {
|
|
10
|
+
const suppliedId = 'project-with-an-explicit-id';
|
|
11
|
+
const received = vi.fn();
|
|
12
|
+
let SceneDataTable;
|
|
13
|
+
let bindings;
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
vi.resetModules();
|
|
16
|
+
received.mockClear();
|
|
17
|
+
vi.doMock('@cratis/components/DataTables', () => ({
|
|
18
|
+
DataTableForQuery: (properties) => {
|
|
19
|
+
received(properties);
|
|
20
|
+
return _jsx("div", { "data-testid": 'query-table' });
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
bindings = await import('../../bindings');
|
|
24
|
+
bindings.clearBindings();
|
|
25
|
+
bindings.registerQuery('InvoicesForProject', InvoicesForProject);
|
|
26
|
+
bindings.registerQuery('AnotherQuery', AnotherQuery);
|
|
27
|
+
({ SceneDataTable } = await import('../SceneDataTable'));
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
cleanup();
|
|
31
|
+
bindings.clearBindings();
|
|
32
|
+
vi.doUnmock('@cratis/components/DataTables');
|
|
33
|
+
vi.resetModules();
|
|
34
|
+
});
|
|
35
|
+
async function renderTable(properties) {
|
|
36
|
+
const element = externalComponent('Cratis.Components:dataTable', properties);
|
|
37
|
+
await act(async () => {
|
|
38
|
+
render(_jsx(SceneDataTable, { element: element, slots: {} }));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
it('should pass the exact registered constructor and explicit projectId object through the runtime boundary', async () => {
|
|
42
|
+
const queryArguments = { projectId: suppliedId };
|
|
43
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
44
|
+
await screen.findByTestId('query-table');
|
|
45
|
+
const properties = received.mock.lastCall[0];
|
|
46
|
+
(properties.query === InvoicesForProject).should.equal(true);
|
|
47
|
+
(properties.queryArguments === queryArguments).should.equal(true);
|
|
48
|
+
properties.should.have.property('queryArguments').that.deep.equals({ projectId: suppliedId });
|
|
49
|
+
});
|
|
50
|
+
it('should preserve all supplied keys and values without normalization or defaults', async () => {
|
|
51
|
+
const queryArguments = { projectId: suppliedId, ProjectID: 'distinct', limit: 0, enabled: false, optional: null, filter: { names: ['one'] } };
|
|
52
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
53
|
+
await screen.findByTestId('query-table');
|
|
54
|
+
(received.mock.lastCall[0].queryArguments === queryArguments).should.equal(true);
|
|
55
|
+
});
|
|
56
|
+
it('should leave omitted arguments absent from the underlying component props', async () => {
|
|
57
|
+
await renderTable({ query: 'InvoicesForProject' });
|
|
58
|
+
await screen.findByTestId('query-table');
|
|
59
|
+
Object.prototype.hasOwnProperty.call(received.mock.lastCall[0], 'queryArguments').should.equal(false);
|
|
60
|
+
(received.mock.lastCall[0].query === InvoicesForProject).should.equal(true);
|
|
61
|
+
});
|
|
62
|
+
it('should treat undefined arguments as omitted like the existing property readers', async () => {
|
|
63
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments: undefined });
|
|
64
|
+
await screen.findByTestId('query-table');
|
|
65
|
+
Object.prototype.hasOwnProperty.call(received.mock.lastCall[0], 'queryArguments').should.equal(false);
|
|
66
|
+
});
|
|
67
|
+
it('should pass an explicitly empty argument object unchanged', async () => {
|
|
68
|
+
const queryArguments = {};
|
|
69
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
70
|
+
await screen.findByTestId('query-table');
|
|
71
|
+
(received.mock.lastCall[0].queryArguments === queryArguments).should.equal(true);
|
|
72
|
+
});
|
|
73
|
+
for (const queryArguments of [[], ['project'], 'project', '{"projectId":"project"}', 42, false, null]) {
|
|
74
|
+
it(`should visibly reject ${JSON.stringify(queryArguments)} without mounting a query table`, async () => {
|
|
75
|
+
await renderTable({ query: 'InvoicesForProject', queryArguments });
|
|
76
|
+
(screen.getByText("Invalid queryArguments: expected an object on Cratis.Components:dataTable") !== null).should.equal(true);
|
|
77
|
+
received.mock.calls.should.have.lengthOf(0);
|
|
78
|
+
(screen.queryByTestId('query-table') === null).should.equal(true);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const queryArguments of [{ projectId: suppliedId }, null, []]) {
|
|
82
|
+
it(`should retain MissingBinding precedence and never choose another registered query with ${JSON.stringify(queryArguments)}`, async () => {
|
|
83
|
+
await renderTable({ query: 'UnregisteredQuery', queryArguments });
|
|
84
|
+
(screen.getByText("Unresolved query binding 'UnregisteredQuery' on Cratis.Components:dataTable") !== null).should.equal(true);
|
|
85
|
+
received.mock.calls.should.have.lengthOf(0);
|
|
86
|
+
(screen.queryByText(/Invalid queryArguments/) === null).should.equal(true);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=when_forwarding_query_arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_forwarding_query_arguments.js","sourceRoot":"","sources":["../../../../data/for_SceneDataTable/when_forwarding_query_arguments.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,EAAE,EAA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E;YACtI,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,CAAC;YAClE,CAAC,MAAM,CAAC,SAAS,CAAC,6EAA6E,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC9H,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC,MAAM,CAAC,WAAW,CAAC,wBAAwB,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_describing_query_arguments.d.ts","sourceRoot":"","sources":["../../../for_cratisComponentsPackage/when_describing_query_arguments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cratisComponentsPackageManifest } from '../cratisComponentsPackage';
|
|
2
|
+
describe('when describing query arguments', () => {
|
|
3
|
+
it('should keep both collection table names in the manifest', () => {
|
|
4
|
+
cratisComponentsPackageManifest.components.should.include('dataTable');
|
|
5
|
+
cratisComponentsPackageManifest.components.should.include('table');
|
|
6
|
+
});
|
|
7
|
+
it('should describe the optional object property without promising single-result support', () => {
|
|
8
|
+
(cratisComponentsPackageManifest.description ?? '').should.contain('dataTable and table accept optional object-valued queryArguments for collection queries');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=when_describing_query_arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_describing_query_arguments.js","sourceRoot":"","sources":["../../../for_cratisComponentsPackage/when_describing_query_arguments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAE7E,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAC/D,+BAA+B,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACvE,+BAA+B,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC5F,CAAC,+BAA+B,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,yFAAyF,CAAC,CAAC;IAClK,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|