@cratis/scene.react 4.2.1 → 4.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/SceneElementView.tsx +13 -4
- package/core/CoreNavigationBar.tsx +59 -0
- package/core/coreComponents.ts +2 -0
- package/core/coreDescriptors.ts +75 -0
- package/core/corePackage.ts +3 -0
- package/core/index.ts +2 -0
- package/dist/cjs/SceneElementView.js +6 -2
- package/dist/cjs/SceneElementView.js.map +1 -1
- package/dist/cjs/core/CoreNavigationBar.js +59 -0
- package/dist/cjs/core/CoreNavigationBar.js.map +1 -0
- package/dist/cjs/core/coreComponents.js +3 -1
- package/dist/cjs/core/coreComponents.js.map +1 -1
- package/dist/cjs/core/coreDescriptors.js +162 -0
- package/dist/cjs/core/coreDescriptors.js.map +1 -0
- package/dist/cjs/core/corePackage.js +5 -2
- package/dist/cjs/core/corePackage.js.map +1 -1
- package/dist/cjs/icons/IconAdapterContext.js +21 -0
- package/dist/cjs/icons/IconAdapterContext.js.map +1 -0
- package/dist/cjs/icons/IconAdapterRegistry.js +45 -0
- package/dist/cjs/icons/IconAdapterRegistry.js.map +1 -0
- package/dist/cjs/icons/SceneIcon.js +42 -0
- package/dist/cjs/icons/SceneIcon.js.map +1 -0
- package/dist/cjs/icons/useIconGlyph.js +86 -0
- package/dist/cjs/icons/useIconGlyph.js.map +1 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/packages/ScenePackageBundle.js +74 -1
- package/dist/cjs/packages/ScenePackageBundle.js.map +1 -1
- package/dist/esm/SceneElementView.d.ts +3 -2
- package/dist/esm/SceneElementView.d.ts.map +1 -1
- package/dist/esm/SceneElementView.js +7 -3
- package/dist/esm/SceneElementView.js.map +1 -1
- package/dist/esm/core/CoreNavigationBar.d.ts +3 -0
- package/dist/esm/core/CoreNavigationBar.d.ts.map +1 -0
- package/dist/esm/core/CoreNavigationBar.js +57 -0
- package/dist/esm/core/CoreNavigationBar.js.map +1 -0
- package/dist/esm/core/coreComponents.d.ts.map +1 -1
- package/dist/esm/core/coreComponents.js +3 -1
- package/dist/esm/core/coreComponents.js.map +1 -1
- package/dist/esm/core/coreDescriptors.d.ts +3 -0
- package/dist/esm/core/coreDescriptors.d.ts.map +1 -0
- package/dist/esm/core/coreDescriptors.js +160 -0
- package/dist/esm/core/coreDescriptors.js.map +1 -0
- package/dist/esm/core/corePackage.d.ts.map +1 -1
- package/dist/esm/core/corePackage.js +5 -2
- package/dist/esm/core/corePackage.js.map +1 -1
- package/dist/esm/core/index.d.ts +2 -0
- package/dist/esm/core/index.d.ts.map +1 -1
- package/dist/esm/core/index.js +2 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/icons/IconAdapter.d.ts +13 -0
- package/dist/esm/icons/IconAdapter.d.ts.map +1 -0
- package/dist/esm/icons/IconAdapter.js +2 -0
- package/dist/esm/icons/IconAdapter.js.map +1 -0
- package/dist/esm/icons/IconAdapterContext.d.ts +8 -0
- package/dist/esm/icons/IconAdapterContext.d.ts.map +1 -0
- package/dist/esm/icons/IconAdapterContext.js +18 -0
- package/dist/esm/icons/IconAdapterContext.js.map +1 -0
- package/dist/esm/icons/IconAdapterRegistry.d.ts +9 -0
- package/dist/esm/icons/IconAdapterRegistry.d.ts.map +1 -0
- package/dist/esm/icons/IconAdapterRegistry.js +42 -0
- package/dist/esm/icons/IconAdapterRegistry.js.map +1 -0
- package/dist/esm/icons/IconLibraryBundle.d.ts +7 -0
- package/dist/esm/icons/IconLibraryBundle.d.ts.map +1 -0
- package/dist/esm/icons/IconLibraryBundle.js +2 -0
- package/dist/esm/icons/IconLibraryBundle.js.map +1 -0
- package/dist/esm/icons/SceneIcon.d.ts +14 -0
- package/dist/esm/icons/SceneIcon.d.ts.map +1 -0
- package/dist/esm/icons/SceneIcon.js +40 -0
- package/dist/esm/icons/SceneIcon.js.map +1 -0
- package/dist/esm/icons/index.d.ts +7 -0
- package/dist/esm/icons/index.d.ts.map +1 -0
- package/dist/esm/icons/index.js +7 -0
- package/dist/esm/icons/index.js.map +1 -0
- package/dist/esm/icons/useIconGlyph.d.ts +14 -0
- package/dist/esm/icons/useIconGlyph.d.ts.map +1 -0
- package/dist/esm/icons/useIconGlyph.js +84 -0
- package/dist/esm/icons/useIconGlyph.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.d.ts +6 -1
- package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -1
- package/dist/esm/packages/ScenePackageBundle.js +74 -2
- package/dist/esm/packages/ScenePackageBundle.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/icons/IconAdapter.ts +52 -0
- package/icons/IconAdapterContext.tsx +21 -0
- package/icons/IconAdapterRegistry.ts +50 -0
- package/icons/IconLibraryBundle.ts +25 -0
- package/icons/SceneIcon.tsx +73 -0
- package/icons/index.ts +9 -0
- package/icons/useIconGlyph.ts +79 -0
- package/index.ts +1 -0
- package/package.json +5 -5
- package/packages/ScenePackageBundle.ts +106 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* The icon adapters a renderer has, one per library. Registering is explicit and never replaces: two
|
|
7
|
+
* adapters for one library would mean an icon renders differently depending on registration order, which
|
|
8
|
+
* is the silent swapping the library-qualified reference exists to prevent.
|
|
9
|
+
*/ class IconAdapterRegistry {
|
|
10
|
+
#adapters = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Adds an adapter.
|
|
13
|
+
*
|
|
14
|
+
* @throws Error when an adapter for the same library is already registered.
|
|
15
|
+
*/ register(adapter) {
|
|
16
|
+
if (this.#adapters.has(adapter.library)) {
|
|
17
|
+
throw new Error(`An icon adapter for the library '${adapter.library}' is already registered`);
|
|
18
|
+
}
|
|
19
|
+
this.#adapters.set(adapter.library, adapter);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The adapter for a library, or `undefined` when this renderer has none.
|
|
24
|
+
*/ get(library) {
|
|
25
|
+
return this.#adapters.get(library);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The libraries this registry can render.
|
|
29
|
+
*/ get libraries() {
|
|
30
|
+
return [
|
|
31
|
+
...this.#adapters.keys()
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a registry holding the given adapters.
|
|
37
|
+
*/ function createIconAdapterRegistry(adapters = []) {
|
|
38
|
+
const registry = new IconAdapterRegistry();
|
|
39
|
+
adapters.forEach((adapter)=>registry.register(adapter));
|
|
40
|
+
return registry;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.IconAdapterRegistry = IconAdapterRegistry;
|
|
44
|
+
exports.createIconAdapterRegistry = createIconAdapterRegistry;
|
|
45
|
+
//# sourceMappingURL=IconAdapterRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconAdapterRegistry.js","sources":["../../../icons/IconAdapterRegistry.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 { IconAdapter } from './IconAdapter';\n\n/**\n * The icon adapters a renderer has, one per library. Registering is explicit and never replaces: two\n * adapters for one library would mean an icon renders differently depending on registration order, which\n * is the silent swapping the library-qualified reference exists to prevent.\n */\nexport class IconAdapterRegistry {\n readonly #adapters = new Map<string, IconAdapter>();\n\n /**\n * Adds an adapter.\n *\n * @throws Error when an adapter for the same library is already registered.\n */\n register(adapter: IconAdapter): this {\n if (this.#adapters.has(adapter.library)) {\n throw new Error(`An icon adapter for the library '${adapter.library}' is already registered`);\n }\n\n this.#adapters.set(adapter.library, adapter);\n return this;\n }\n\n /**\n * The adapter for a library, or `undefined` when this renderer has none.\n */\n get(library: string): IconAdapter | undefined {\n return this.#adapters.get(library);\n }\n\n /**\n * The libraries this registry can render.\n */\n get libraries(): string[] {\n return [...this.#adapters.keys()];\n }\n}\n\n/**\n * Creates a registry holding the given adapters.\n */\nexport function createIconAdapterRegistry(adapters: IconAdapter[] = []): IconAdapterRegistry {\n const registry = new IconAdapterRegistry();\n adapters.forEach((adapter) => registry.register(adapter));\n return registry;\n}\n"],"names":["IconAdapterRegistry","Map","register","adapter","has","library","Error","set","get","libraries","keys","createIconAdapterRegistry","adapters","registry","forEach"],"mappings":";;AAAA;AACA;AAIA;;;;AAIC,IACM,MAAMA,mBAAAA,CAAAA;IACA,SAAS,GAAG,IAAIC,GAAAA,EAAAA;AAEzB;;;;QAKAC,QAAAA,CAASC,OAAoB,EAAQ;QACjC,IAAI,IAAI,CAAC,SAAS,CAACC,GAAG,CAACD,OAAAA,CAAQE,OAAO,CAAA,EAAG;YACrC,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEH,OAAAA,CAAQE,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAChG,QAAA;QAEA,IAAI,CAAC,SAAS,CAACE,GAAG,CAACJ,OAAAA,CAAQE,OAAO,EAAEF,OAAAA,CAAAA;AACpC,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;QAGAK,GAAAA,CAAIH,OAAe,EAA2B;AAC1C,QAAA,OAAO,IAAI,CAAC,SAAS,CAACG,GAAG,CAACH,OAAAA,CAAAA;AAC9B,IAAA;AAEA;;AAEC,QACD,IAAII,SAAAA,GAAsB;QACtB,OAAO;AAAI,YAAA,GAAA,IAAI,CAAC,SAAS,CAACC,IAAI;AAAG,SAAA;AACrC,IAAA;AACJ;AAEA;;AAEC,IACM,SAASC,yBAAAA,CAA0BC,QAAAA,GAA0B,EAAE,EAAA;AAClE,IAAA,MAAMC,WAAW,IAAIb,mBAAAA,EAAAA;AACrBY,IAAAA,QAAAA,CAASE,OAAO,CAAC,CAACX,OAAAA,GAAYU,QAAAA,CAASX,QAAQ,CAACC,OAAAA,CAAAA,CAAAA;IAChD,OAAOU,QAAAA;AACX;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var IconAdapterContext = require('./IconAdapterContext.js');
|
|
5
|
+
var useIconGlyph = require('./useIconGlyph.js');
|
|
6
|
+
|
|
7
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
8
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
9
|
+
/**
|
|
10
|
+
* Draws a renderer-neutral {@link IconReference} through the adapter registered for its library, honoring
|
|
11
|
+
* size, color and accessible label. The reference is all that is persisted; this is where it becomes pixels.
|
|
12
|
+
*/ const SceneIcon = ({ reference, adapters, size = '1em', color = 'currentColor', label, className, fallback })=>{
|
|
13
|
+
const inScope = IconAdapterContext.useIconAdapters();
|
|
14
|
+
const state = useIconGlyph.useIconGlyph(reference, adapters ?? inScope);
|
|
15
|
+
const Glyph = state.status === 'ready' ? state.glyph : undefined;
|
|
16
|
+
return /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
17
|
+
className: className,
|
|
18
|
+
role: label ? 'img' : undefined,
|
|
19
|
+
"aria-label": label,
|
|
20
|
+
"aria-hidden": label ? undefined : true,
|
|
21
|
+
"data-icon-library": reference.library,
|
|
22
|
+
"data-icon-key": reference.key,
|
|
23
|
+
"data-icon-variant": reference.variant,
|
|
24
|
+
"data-icon-state": state.status,
|
|
25
|
+
style: {
|
|
26
|
+
display: 'inline-flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
width: size,
|
|
30
|
+
height: size,
|
|
31
|
+
color,
|
|
32
|
+
flexShrink: 0
|
|
33
|
+
},
|
|
34
|
+
children: Glyph ? /*#__PURE__*/ jsxRuntime.jsx(Glyph, {
|
|
35
|
+
size: size,
|
|
36
|
+
color: color
|
|
37
|
+
}) : state.status === 'unavailable' ? fallback : null
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.SceneIcon = SceneIcon;
|
|
42
|
+
//# sourceMappingURL=SceneIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneIcon.js","sources":["../../../icons/SceneIcon.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 { ReactNode } from 'react';\nimport { IconReference } from '@cratis/scene.model';\nimport { IconAdapterRegistry } from './IconAdapterRegistry';\nimport { useIconAdapters } from './IconAdapterContext';\nimport { useIconGlyph } from './useIconGlyph';\n\nexport interface SceneIconProps {\n /**\n * The icon to draw.\n */\n reference: IconReference;\n\n /**\n * The adapters to render through. Defaults to the ones an `IconAdapterProvider` supplies.\n */\n adapters?: IconAdapterRegistry;\n\n /**\n * The width and height of the icon: a number of pixels or any CSS length. Defaults to `1em`, so an\n * icon scales with the text it sits in.\n */\n size?: number | string;\n\n /**\n * The color to draw in. Defaults to `currentColor`.\n */\n color?: string;\n\n /**\n * The accessible name. With a label the icon is announced as an image; without one it is decorative\n * and hidden from assistive technology - an icon next to its own text label should not be read twice.\n */\n label?: string;\n\n /**\n * An optional class for the box the icon sits in.\n */\n className?: string;\n\n /**\n * What to show when the icon cannot be drawn - no adapter, no such icon, a failed load. Nothing by\n * default; the box keeps its size so layout does not shift.\n */\n fallback?: ReactNode;\n}\n\n/**\n * Draws a renderer-neutral {@link IconReference} through the adapter registered for its library, honoring\n * size, color and accessible label. The reference is all that is persisted; this is where it becomes pixels.\n */\nexport const SceneIcon = ({ reference, adapters, size = '1em', color = 'currentColor', label, className, fallback }: SceneIconProps) => {\n const inScope = useIconAdapters();\n const state = useIconGlyph(reference, adapters ?? inScope);\n const Glyph = state.status === 'ready' ? state.glyph : undefined;\n\n return (\n <span\n className={className}\n role={label ? 'img' : undefined}\n aria-label={label}\n aria-hidden={label ? undefined : true}\n data-icon-library={reference.library}\n data-icon-key={reference.key}\n data-icon-variant={reference.variant}\n data-icon-state={state.status}\n style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: size, height: size, color, flexShrink: 0 }}>\n {Glyph ? <Glyph size={size} color={color} /> : state.status === 'unavailable' ? fallback : null}\n </span>\n );\n};\n"],"names":["SceneIcon","reference","adapters","size","color","label","className","fallback","inScope","useIconAdapters","state","useIconGlyph","Glyph","status","glyph","undefined","_jsx","span","role","aria-label","aria-hidden","data-icon-library","library","data-icon-key","key","data-icon-variant","variant","data-icon-state","style","display","alignItems","justifyContent","width","height","flexShrink"],"mappings":";;;;;;AAAA;AACA;AAgDA;;;UAIaA,SAAAA,GAAY,CAAC,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,IAAAA,GAAO,KAAK,EAAEC,KAAAA,GAAQ,cAAc,EAAEC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAkB,GAAA;AAC/H,IAAA,MAAMC,OAAAA,GAAUC,kCAAAA,EAAAA;IAChB,MAAMC,KAAAA,GAAQC,yBAAAA,CAAaV,SAAAA,EAAWC,QAAAA,IAAYM,OAAAA,CAAAA;AAClD,IAAA,MAAMI,QAAQF,KAAAA,CAAMG,MAAM,KAAK,OAAA,GAAUH,KAAAA,CAAMI,KAAK,GAAGC,SAAAA;AAEvD,IAAA,qBACIC,cAAA,CAACC,MAAAA,EAAAA;QACGX,SAAAA,EAAWA,SAAAA;AACXY,QAAAA,IAAAA,EAAMb,QAAQ,KAAA,GAAQU,SAAAA;QACtBI,YAAAA,EAAYd,KAAAA;AACZe,QAAAA,aAAAA,EAAaf,QAAQU,SAAAA,GAAY,IAAA;AACjCM,QAAAA,mBAAAA,EAAmBpB,UAAUqB,OAAO;AACpCC,QAAAA,eAAAA,EAAetB,UAAUuB,GAAG;AAC5BC,QAAAA,mBAAAA,EAAmBxB,UAAUyB,OAAO;AACpCC,QAAAA,iBAAAA,EAAiBjB,MAAMG,MAAM;QAC7Be,KAAAA,EAAO;YAAEC,OAAAA,EAAS,aAAA;YAAeC,UAAAA,EAAY,QAAA;YAAUC,cAAAA,EAAgB,QAAA;YAAUC,KAAAA,EAAO7B,IAAAA;YAAM8B,MAAAA,EAAQ9B,IAAAA;AAAMC,YAAAA,KAAAA;YAAO8B,UAAAA,EAAY;AAAE,SAAA;AAChItB,QAAAA,QAAAA,EAAAA,KAAAA,iBAAQI,cAAA,CAACJ,KAAAA,EAAAA;YAAMT,IAAAA,EAAMA,IAAAA;YAAMC,KAAAA,EAAOA;aAAYM,KAAAA,CAAMG,MAAM,KAAK,aAAA,GAAgBN,QAAAA,GAAW;;AAGvG;;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
const loads = new WeakMap();
|
|
8
|
+
function keyOf(reference) {
|
|
9
|
+
return JSON.stringify([
|
|
10
|
+
reference.key,
|
|
11
|
+
reference.variant ?? null
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One load per adapter and icon, shared between every place the icon is drawn; a failed load is
|
|
16
|
+
* forgotten so the next render can try again.
|
|
17
|
+
*/ function load(adapter, reference) {
|
|
18
|
+
let perAdapter = loads.get(adapter);
|
|
19
|
+
if (!perAdapter) {
|
|
20
|
+
perAdapter = new Map();
|
|
21
|
+
loads.set(adapter, perAdapter);
|
|
22
|
+
}
|
|
23
|
+
const key = keyOf(reference);
|
|
24
|
+
let pending = perAdapter.get(key);
|
|
25
|
+
if (!pending) {
|
|
26
|
+
pending = Promise.resolve().then(()=>adapter.loadGlyph(reference));
|
|
27
|
+
perAdapter.set(key, pending);
|
|
28
|
+
pending.catch(()=>perAdapter.delete(key));
|
|
29
|
+
}
|
|
30
|
+
return pending;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Loads the artwork for a reference through the adapter registered for its library. An absent registry,
|
|
34
|
+
* a library with no adapter, an icon the library lacks and a failed load are all `unavailable`, each with
|
|
35
|
+
* its reason - never a different icon.
|
|
36
|
+
*/ function useIconGlyph(reference, adapters) {
|
|
37
|
+
const [state, setState] = react.useState({
|
|
38
|
+
status: 'loading'
|
|
39
|
+
});
|
|
40
|
+
const { library, key, variant } = reference;
|
|
41
|
+
react.useEffect(()=>{
|
|
42
|
+
let isCurrent = true;
|
|
43
|
+
const adapter = adapters?.get(library);
|
|
44
|
+
if (!adapter) {
|
|
45
|
+
setState({
|
|
46
|
+
status: 'unavailable',
|
|
47
|
+
reason: `No icon adapter is registered for the library '${library}'`
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setState({
|
|
52
|
+
status: 'loading'
|
|
53
|
+
});
|
|
54
|
+
load(adapter, {
|
|
55
|
+
library,
|
|
56
|
+
key,
|
|
57
|
+
variant
|
|
58
|
+
}).then((glyph)=>{
|
|
59
|
+
if (!isCurrent) return;
|
|
60
|
+
setState(glyph ? {
|
|
61
|
+
status: 'ready',
|
|
62
|
+
glyph
|
|
63
|
+
} : {
|
|
64
|
+
status: 'unavailable',
|
|
65
|
+
reason: `The library '${library}' has no icon '${key}'`
|
|
66
|
+
});
|
|
67
|
+
}, (error)=>{
|
|
68
|
+
if (isCurrent) setState({
|
|
69
|
+
status: 'unavailable',
|
|
70
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return ()=>{
|
|
74
|
+
isCurrent = false;
|
|
75
|
+
};
|
|
76
|
+
}, [
|
|
77
|
+
adapters,
|
|
78
|
+
library,
|
|
79
|
+
key,
|
|
80
|
+
variant
|
|
81
|
+
]);
|
|
82
|
+
return state;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
exports.useIconGlyph = useIconGlyph;
|
|
86
|
+
//# sourceMappingURL=useIconGlyph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIconGlyph.js","sources":["../../../icons/useIconGlyph.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 { useEffect, useState } from 'react';\nimport { IconReference } from '@cratis/scene.model';\nimport { IconAdapter, IconGlyph } from './IconAdapter';\nimport { IconAdapterRegistry } from './IconAdapterRegistry';\n\n/**\n * Where loading one icon's artwork stands.\n */\nexport type IconGlyphState =\n | { status: 'loading' }\n | { status: 'ready'; glyph: IconGlyph }\n | { status: 'unavailable'; reason: string };\n\nconst loads = new WeakMap<IconAdapter, Map<string, Promise<IconGlyph | undefined>>>();\n\nfunction keyOf(reference: IconReference): string {\n return JSON.stringify([reference.key, reference.variant ?? null]);\n}\n\n/**\n * One load per adapter and icon, shared between every place the icon is drawn; a failed load is\n * forgotten so the next render can try again.\n */\nfunction load(adapter: IconAdapter, reference: IconReference): Promise<IconGlyph | undefined> {\n let perAdapter = loads.get(adapter);\n if (!perAdapter) {\n perAdapter = new Map();\n loads.set(adapter, perAdapter);\n }\n\n const key = keyOf(reference);\n let pending = perAdapter.get(key);\n if (!pending) {\n pending = Promise.resolve().then(() => adapter.loadGlyph(reference));\n perAdapter.set(key, pending);\n pending.catch(() => perAdapter.delete(key));\n }\n\n return pending;\n}\n\n/**\n * Loads the artwork for a reference through the adapter registered for its library. An absent registry,\n * a library with no adapter, an icon the library lacks and a failed load are all `unavailable`, each with\n * its reason - never a different icon.\n */\nexport function useIconGlyph(reference: IconReference, adapters: IconAdapterRegistry | undefined): IconGlyphState {\n const [state, setState] = useState<IconGlyphState>({ status: 'loading' });\n const { library, key, variant } = reference;\n\n useEffect(() => {\n let isCurrent = true;\n const adapter = adapters?.get(library);\n if (!adapter) {\n setState({ status: 'unavailable', reason: `No icon adapter is registered for the library '${library}'` });\n return;\n }\n\n setState({ status: 'loading' });\n load(adapter, { library, key, variant }).then(\n (glyph) => {\n if (!isCurrent) return;\n setState(glyph ? { status: 'ready', glyph } : { status: 'unavailable', reason: `The library '${library}' has no icon '${key}'` });\n },\n (error: unknown) => {\n if (isCurrent) setState({ status: 'unavailable', reason: error instanceof Error ? error.message : String(error) });\n }\n );\n\n return () => {\n isCurrent = false;\n };\n }, [adapters, library, key, variant]);\n\n return state;\n}\n"],"names":["loads","WeakMap","keyOf","reference","JSON","stringify","key","variant","load","adapter","perAdapter","get","Map","set","pending","Promise","resolve","then","loadGlyph","catch","delete","useIconGlyph","adapters","state","setState","useState","status","library","useEffect","isCurrent","reason","glyph","error","Error","message","String"],"mappings":";;;;AAAA;AACA;AAeA,MAAMA,QAAQ,IAAIC,OAAAA,EAAAA;AAElB,SAASC,MAAMC,SAAwB,EAAA;IACnC,OAAOC,IAAAA,CAAKC,SAAS,CAAC;AAACF,QAAAA,SAAAA,CAAUG,GAAG;AAAEH,QAAAA,SAAAA,CAAUI,OAAO,IAAI;AAAK,KAAA,CAAA;AACpE;AAEA;;;AAGC,IACD,SAASC,IAAAA,CAAKC,OAAoB,EAAEN,SAAwB,EAAA;IACxD,IAAIO,UAAAA,GAAaV,KAAAA,CAAMW,GAAG,CAACF,OAAAA,CAAAA;AAC3B,IAAA,IAAI,CAACC,UAAAA,EAAY;AACbA,QAAAA,UAAAA,GAAa,IAAIE,GAAAA,EAAAA;QACjBZ,KAAAA,CAAMa,GAAG,CAACJ,OAAAA,EAASC,UAAAA,CAAAA;AACvB,IAAA;AAEA,IAAA,MAAMJ,MAAMJ,KAAAA,CAAMC,SAAAA,CAAAA;IAClB,IAAIW,OAAAA,GAAUJ,UAAAA,CAAWC,GAAG,CAACL,GAAAA,CAAAA;AAC7B,IAAA,IAAI,CAACQ,OAAAA,EAAS;QACVA,OAAAA,GAAUC,OAAAA,CAAQC,OAAO,EAAA,CAAGC,IAAI,CAA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;gBAAeI,MAAAA,EAAQ,CAAC,aAAa,EAAEH,OAAAA,CAAQ,eAAe,EAAErB,GAAAA,CAAI,CAAC;AAAE,aAAA,CAAA;AACnI,QAAA,CAAA,EACA,CAAC0B,KAAAA,GAAAA;AACG,YAAA,IAAIH,WAAWL,QAAAA,CAAS;gBAAEE,MAAAA,EAAQ,aAAA;AAAeI,gBAAAA,MAAAA,EAAQE,KAAAA,YAAiBC,KAAAA,GAAQD,KAAAA,CAAME,OAAO,GAAGC,MAAAA,CAAOH,KAAAA;AAAO,aAAA,CAAA;AACpH,QAAA,CAAA,CAAA;QAGJ,OAAO,IAAA;YACHH,SAAAA,GAAY,KAAA;AAChB,QAAA,CAAA;IACJ,CAAA,EAAG;AAACP,QAAAA,QAAAA;AAAUK,QAAAA,OAAAA;AAASrB,QAAAA,GAAAA;AAAKC,QAAAA;AAAQ,KAAA,CAAA;IAEpC,OAAOgB,KAAAA;AACX;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -7,11 +7,17 @@ var InteractiveComponent = require('./renderer/InteractiveComponent.js');
|
|
|
7
7
|
var CoreText = require('./core/CoreText.js');
|
|
8
8
|
var CoreButton = require('./core/CoreButton.js');
|
|
9
9
|
var CoreCard = require('./core/CoreCard.js');
|
|
10
|
+
var CoreNavigationBar = require('./core/CoreNavigationBar.js');
|
|
11
|
+
var coreDescriptors = require('./core/coreDescriptors.js');
|
|
10
12
|
var ScreenplayCoreComponents = require('./core/ScreenplayCoreComponents.js');
|
|
11
13
|
var coreComponents = require('./core/coreComponents.js');
|
|
12
14
|
var corePackage = require('./core/corePackage.js');
|
|
13
15
|
var NavBar = require('./NavBar/NavBar.js');
|
|
14
16
|
var extractNavigationItem = require('./NavBar/extractNavigationItem.js');
|
|
17
|
+
var IconAdapterRegistry = require('./icons/IconAdapterRegistry.js');
|
|
18
|
+
var IconAdapterContext = require('./icons/IconAdapterContext.js');
|
|
19
|
+
var useIconGlyph = require('./icons/useIconGlyph.js');
|
|
20
|
+
var SceneIcon = require('./icons/SceneIcon.js');
|
|
15
21
|
var ScenePackageBundle = require('./packages/ScenePackageBundle.js');
|
|
16
22
|
var themeTokens = require('./theme/themeTokens.js');
|
|
17
23
|
var SceneThemeProvider = require('./theme/SceneThemeProvider.js');
|
|
@@ -32,6 +38,8 @@ exports.InteractiveComponent = InteractiveComponent.InteractiveComponent;
|
|
|
32
38
|
exports.CoreText = CoreText.CoreText;
|
|
33
39
|
exports.CoreButton = CoreButton.CoreButton;
|
|
34
40
|
exports.CoreCard = CoreCard.CoreCard;
|
|
41
|
+
exports.CoreNavigationBar = CoreNavigationBar.CoreNavigationBar;
|
|
42
|
+
exports.coreDescriptors = coreDescriptors.coreDescriptors;
|
|
35
43
|
exports.CoreAction = ScreenplayCoreComponents.CoreAction;
|
|
36
44
|
exports.CoreCode = ScreenplayCoreComponents.CoreCode;
|
|
37
45
|
exports.CoreColumn = ScreenplayCoreComponents.CoreColumn;
|
|
@@ -48,7 +56,14 @@ exports.corePackage = corePackage.corePackage;
|
|
|
48
56
|
exports.corePackageManifest = corePackage.corePackageManifest;
|
|
49
57
|
exports.NavBar = NavBar.NavBar;
|
|
50
58
|
exports.extractNavigationItem = extractNavigationItem.extractNavigationItem;
|
|
59
|
+
exports.IconAdapterRegistry = IconAdapterRegistry.IconAdapterRegistry;
|
|
60
|
+
exports.createIconAdapterRegistry = IconAdapterRegistry.createIconAdapterRegistry;
|
|
61
|
+
exports.IconAdapterProvider = IconAdapterContext.IconAdapterProvider;
|
|
62
|
+
exports.useIconAdapters = IconAdapterContext.useIconAdapters;
|
|
63
|
+
exports.useIconGlyph = useIconGlyph.useIconGlyph;
|
|
64
|
+
exports.SceneIcon = SceneIcon.SceneIcon;
|
|
51
65
|
exports.componentRegistryKey = ScenePackageBundle.componentRegistryKey;
|
|
66
|
+
exports.mergeIconAdapters = ScenePackageBundle.mergeIconAdapters;
|
|
52
67
|
exports.mergePackageRegistries = ScenePackageBundle.mergePackageRegistries;
|
|
53
68
|
exports.validatePackageBundle = ScenePackageBundle.validatePackageBundle;
|
|
54
69
|
exports.applyThemeTokens = themeTokens.applyThemeTokens;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var IconAdapterRegistry = require('../icons/IconAdapterRegistry.js');
|
|
5
|
+
|
|
3
6
|
// Copyright (c) Cratis. All rights reserved.
|
|
4
7
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
8
|
/**
|
|
@@ -15,7 +18,8 @@
|
|
|
15
18
|
return `${packageName}:${componentName}`;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
|
-
* Checks that a bundle provides everything its manifest declares, and declares everything it provides
|
|
21
|
+
* Checks that a bundle provides everything its manifest declares, and declares everything it provides, and that
|
|
22
|
+
* every descriptor it ships is for a component it declares and is well formed.
|
|
19
23
|
*
|
|
20
24
|
* A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at
|
|
21
25
|
* runtime — a blank box, far from where the mistake was made. A component registered but not declared is
|
|
@@ -59,6 +63,65 @@
|
|
|
59
63
|
problems.push(`declares the theme '${name}' but provides no definition for it`);
|
|
60
64
|
}
|
|
61
65
|
}
|
|
66
|
+
problems.push(...validateIconLibrary(bundle));
|
|
67
|
+
problems.push(...validateDescriptors(bundle));
|
|
68
|
+
return problems;
|
|
69
|
+
}
|
|
70
|
+
function validateIconLibrary(bundle) {
|
|
71
|
+
const problems = [];
|
|
72
|
+
const { manifest, iconLibrary } = bundle;
|
|
73
|
+
const declaresIconLibrary = manifest.kind === scene_model.PackageKind.IconLibrary || manifest.iconLibrary !== undefined;
|
|
74
|
+
if (manifest.kind === scene_model.PackageKind.IconLibrary && !manifest.iconLibrary) {
|
|
75
|
+
problems.push('is an icon library but declares no iconLibrary metadata');
|
|
76
|
+
}
|
|
77
|
+
if (manifest.kind !== scene_model.PackageKind.IconLibrary && manifest.iconLibrary) {
|
|
78
|
+
problems.push('declares iconLibrary metadata but is not of kind IconLibrary');
|
|
79
|
+
}
|
|
80
|
+
if (declaresIconLibrary && !iconLibrary) {
|
|
81
|
+
problems.push('declares an icon library but the bundle provides no catalog or adapter for it');
|
|
82
|
+
}
|
|
83
|
+
if (!declaresIconLibrary && iconLibrary) {
|
|
84
|
+
problems.push('provides an icon catalog and adapter, which the manifest does not declare');
|
|
85
|
+
}
|
|
86
|
+
if (iconLibrary) {
|
|
87
|
+
if (iconLibrary.catalog.library !== manifest.name) {
|
|
88
|
+
problems.push(`provides an icon catalog for '${iconLibrary.catalog.library}' instead of '${manifest.name}'`);
|
|
89
|
+
}
|
|
90
|
+
if (iconLibrary.adapter.library !== manifest.name) {
|
|
91
|
+
problems.push(`provides an icon adapter for '${iconLibrary.adapter.library}' instead of '${manifest.name}'`);
|
|
92
|
+
}
|
|
93
|
+
if (manifest.iconLibrary && !manifest.iconLibrary.renderers.includes('react')) {
|
|
94
|
+
problems.push("provides a React icon adapter but does not list 'react' among its icon renderers");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return problems;
|
|
98
|
+
}
|
|
99
|
+
function validateDescriptors(bundle) {
|
|
100
|
+
const problems = [];
|
|
101
|
+
const declared = new Set(bundle.manifest.components.map((name)=>componentRegistryKey(bundle.manifest.name, name)));
|
|
102
|
+
const described = new Set();
|
|
103
|
+
for (const descriptor of bundle.descriptors ?? []){
|
|
104
|
+
if (!declared.has(descriptor.component)) {
|
|
105
|
+
problems.push(`describes '${descriptor.component}', which the manifest does not declare as a component`);
|
|
106
|
+
}
|
|
107
|
+
if (described.has(descriptor.component)) {
|
|
108
|
+
problems.push(`describes '${descriptor.component}' more than once`);
|
|
109
|
+
}
|
|
110
|
+
described.add(descriptor.component);
|
|
111
|
+
const paths = new Set();
|
|
112
|
+
for (const property of descriptor.properties){
|
|
113
|
+
if (paths.has(property.path)) {
|
|
114
|
+
problems.push(`'${descriptor.component}' describes the property '${property.path}' more than once`);
|
|
115
|
+
}
|
|
116
|
+
paths.add(property.path);
|
|
117
|
+
if (property.valueType === scene_model.PropertyValueType.Collection && property.item === undefined) {
|
|
118
|
+
problems.push(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);
|
|
119
|
+
}
|
|
120
|
+
if (property.valueType === scene_model.PropertyValueType.Enum && (property.choices ?? []).length === 0) {
|
|
121
|
+
problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
62
125
|
return problems;
|
|
63
126
|
}
|
|
64
127
|
/**
|
|
@@ -69,8 +132,18 @@
|
|
|
69
132
|
*/ function mergePackageRegistries(bundles) {
|
|
70
133
|
return Object.assign({}, ...bundles.map((bundle)=>bundle.components));
|
|
71
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Collects the icon adapters of several bundles into the registry `SceneIcon` renders through.
|
|
137
|
+
*
|
|
138
|
+
* @throws Error when two bundles provide an adapter for the same library.
|
|
139
|
+
*/ function mergeIconAdapters(bundles) {
|
|
140
|
+
return IconAdapterRegistry.createIconAdapterRegistry(bundles.flatMap((bundle)=>bundle.iconLibrary ? [
|
|
141
|
+
bundle.iconLibrary.adapter
|
|
142
|
+
] : []));
|
|
143
|
+
}
|
|
72
144
|
|
|
73
145
|
exports.componentRegistryKey = componentRegistryKey;
|
|
146
|
+
exports.mergeIconAdapters = mergeIconAdapters;
|
|
74
147
|
exports.mergePackageRegistries = mergePackageRegistries;
|
|
75
148
|
exports.validatePackageBundle = validatePackageBundle;
|
|
76
149
|
//# sourceMappingURL=ScenePackageBundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.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 { DialogTemplate, Layout, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry } from '../renderer';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","mergePackageRegistries","bundles","assign"],"mappings":";;AAAA;AACA;AAyDA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;IAQO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,CAAAA,CAAAA;AAC/F,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAO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AAAA,CAASkB,eAAe,CAAE;AACzC,QAAA,IAAI,CAACD,uBAAAA,CAAwBP,GAAG,CAACT,IAAAA,CAAAA,EAAO;AACpCF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,8BAA8B,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAC5F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMkB,iBAAiB,IAAId,GAAAA,CAAI,CAACP,OAAOsB,MAAM,IAAI,EAAC,EAAGd,GAAG,CAAC,CAACe,KAAAA,GAAUA,MAAMpB,IAAI,CAAA,CAAA;AAC9E,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASoB,MAAM,CAAE;AAChC,QAAA,IAAI,CAACD,cAAAA,CAAeT,GAAG,CAACT,IAAAA,CAAAA,EAAO;AAC3BF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,oBAAoB,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAClF,QAAA;AACJ,IAAA;IAEA,OAAOF,QAAAA;AACX;AAEA;;;;;IAMO,SAASuB,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOf,MAAAA,CAAOgB,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQjB,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;;;;"}
|
|
1
|
+
{"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.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 { ComponentDescriptor, DialogTemplate, Layout, PackageKind, PropertyValueType, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { IconAdapterRegistry, createIconAdapterRegistry } from '../icons/IconAdapterRegistry';\nimport { IconLibraryBundle } from '../icons/IconLibraryBundle';\nimport { ComponentRegistry } from '../renderer';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * What can be edited on this package's components - one {@link ComponentDescriptor} per component that is\n * editable at design time. They are data, so Studio reads them without rendering anything, and they travel with\n * the components they describe rather than in a registry of their own. {@link validatePackageBundle} checks\n * that every descriptor names a component the manifest declares.\n */\n descriptors?: ComponentDescriptor[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n\n /**\n * The icon catalog and renderer adapter of an icon-library package. Present exactly when the\n * manifest declares an icon library.\n */\n iconLibrary?: IconLibraryBundle;\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides, and that\n * every descriptor it ships is for a component it declares and is well formed.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n problems.push(...validateIconLibrary(bundle));\n problems.push(...validateDescriptors(bundle));\n\n return problems;\n}\n\nfunction validateIconLibrary(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest, iconLibrary } = bundle;\n const declaresIconLibrary = manifest.kind === PackageKind.IconLibrary || manifest.iconLibrary !== undefined;\n\n if (manifest.kind === PackageKind.IconLibrary && !manifest.iconLibrary) {\n problems.push('is an icon library but declares no iconLibrary metadata');\n }\n\n if (manifest.kind !== PackageKind.IconLibrary && manifest.iconLibrary) {\n problems.push('declares iconLibrary metadata but is not of kind IconLibrary');\n }\n\n if (declaresIconLibrary && !iconLibrary) {\n problems.push('declares an icon library but the bundle provides no catalog or adapter for it');\n }\n\n if (!declaresIconLibrary && iconLibrary) {\n problems.push('provides an icon catalog and adapter, which the manifest does not declare');\n }\n\n if (iconLibrary) {\n if (iconLibrary.catalog.library !== manifest.name) {\n problems.push(`provides an icon catalog for '${iconLibrary.catalog.library}' instead of '${manifest.name}'`);\n }\n\n if (iconLibrary.adapter.library !== manifest.name) {\n problems.push(`provides an icon adapter for '${iconLibrary.adapter.library}' instead of '${manifest.name}'`);\n }\n\n if (manifest.iconLibrary && !manifest.iconLibrary.renderers.includes('react')) {\n problems.push(\"provides a React icon adapter but does not list 'react' among its icon renderers\");\n }\n }\n\n return problems;\n}\n\nfunction validateDescriptors(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const declared = new Set(bundle.manifest.components.map((name) => componentRegistryKey(bundle.manifest.name, name)));\n const described = new Set<string>();\n\n for (const descriptor of bundle.descriptors ?? []) {\n if (!declared.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}', which the manifest does not declare as a component`);\n }\n\n if (described.has(descriptor.component)) {\n problems.push(`describes '${descriptor.component}' more than once`);\n }\n\n described.add(descriptor.component);\n\n const paths = new Set<string>();\n for (const property of descriptor.properties) {\n if (paths.has(property.path)) {\n problems.push(`'${descriptor.component}' describes the property '${property.path}' more than once`);\n }\n\n paths.add(property.path);\n\n if (property.valueType === PropertyValueType.Collection && property.item === undefined) {\n problems.push(`'${descriptor.component}' describes the collection '${property.path}' without describing its items`);\n }\n\n if (property.valueType === PropertyValueType.Enum && (property.choices ?? []).length === 0) {\n problems.push(`'${descriptor.component}' describes the enum '${property.path}' without choices`);\n }\n }\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n\n/**\n * Collects the icon adapters of several bundles into the registry `SceneIcon` renders through.\n *\n * @throws Error when two bundles provide an adapter for the same library.\n */\nexport function mergeIconAdapters(bundles: ScenePackageBundle[]): IconAdapterRegistry {\n return createIconAdapterRegistry(bundles.flatMap((bundle) => (bundle.iconLibrary ? [bundle.iconLibrary.adapter] : [])));\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","validateIconLibrary","validateDescriptors","iconLibrary","declaresIconLibrary","kind","PackageKind","IconLibrary","undefined","catalog","library","adapter","renderers","includes","described","descriptor","descriptors","component","add","paths","property","properties","path","valueType","PropertyValueType","Collection","item","Enum","choices","length","mergePackageRegistries","bundles","assign","mergeIconAdapters","createIconAdapterRegistry","flatMap"],"mappings":";;;;;AAAA;AACA;AAyEA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;;IASO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAq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C,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQ9C,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;AAEA;;;;IAKO,SAASoD,iBAAAA,CAAkBF,OAA6B,EAAA;IAC3D,OAAOG,6CAAAA,CAA0BH,QAAQI,OAAO,CAAC,CAAC1D,MAAAA,GAAYA,MAAAA,CAAO0B,WAAW,GAAG;YAAC1B,MAAAA,CAAO0B,WAAW,CAACQ;AAAQ,SAAA,GAAG,EAAE,CAAA,CAAA;AACxH;;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BindingResolver } from '@cratis/scene.engine';
|
|
2
|
-
import { SceneElement } from '@cratis/scene.model';
|
|
2
|
+
import { EffectiveConfiguration, SceneElement } from '@cratis/scene.model';
|
|
3
3
|
import { ComponentRegistry } from './renderer';
|
|
4
4
|
export interface SceneElementViewProps {
|
|
5
5
|
element: SceneElement;
|
|
6
6
|
registry: ComponentRegistry;
|
|
7
7
|
resolveBinding: BindingResolver;
|
|
8
|
+
configuration?: EffectiveConfiguration;
|
|
8
9
|
}
|
|
9
|
-
export declare function SceneElementView({ element, registry, resolveBinding }: SceneElementViewProps): import("react").JSX.Element;
|
|
10
|
+
export declare function SceneElementView({ element, registry, resolveBinding, configuration }: SceneElementViewProps): import("react").JSX.Element;
|
|
10
11
|
//# sourceMappingURL=SceneElementView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneElementView.d.ts","sourceRoot":"","sources":["../../SceneElementView.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"SceneElementView.d.ts","sourceRoot":"","sources":["../../SceneElementView.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA8C,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAuB,MAAM,YAAY,CAAC;AAEpE,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,cAAc,EAAE,eAAe,CAAC;IAQhC,aAAa,CAAC,EAAE,sBAAsB,CAAC;CAC1C;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,EAAE,qBAAqB,+BAI3G"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { renderElement } from '@cratis/scene.engine';
|
|
3
|
+
import { applyEffectiveConfiguration, renderElement } from '@cratis/scene.engine';
|
|
4
4
|
import { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
5
5
|
import './interactions/useInteractions.js';
|
|
6
6
|
import './interactions/NotificationHost.js';
|
|
@@ -8,12 +8,16 @@ import './interactions/NotificationHost.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's
|
|
10
10
|
* preview surface and Stage's shipped web bundle both consume unmodified.
|
|
11
|
-
*/ function SceneElementView({ element, registry, resolveBinding }) {
|
|
11
|
+
*/ function SceneElementView({ element, registry, resolveBinding, configuration }) {
|
|
12
12
|
const renderer = useMemo(()=>createReactRenderer(registry), [
|
|
13
13
|
registry
|
|
14
14
|
]);
|
|
15
|
+
const configured = useMemo(()=>configuration ? applyEffectiveConfiguration(element, configuration) : element, [
|
|
16
|
+
element,
|
|
17
|
+
configuration
|
|
18
|
+
]);
|
|
15
19
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
16
|
-
children: renderElement(
|
|
20
|
+
children: renderElement(configured, renderer, resolveBinding)
|
|
17
21
|
});
|
|
18
22
|
}
|
|
19
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneElementView.js","sources":["../../SceneElementView.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 { useMemo } from 'react';\nimport { renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, createReactRenderer } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding: BindingResolver;\n}\n\n/**\n * Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's\n * preview surface and Stage's shipped web bundle both consume unmodified.\n */\nexport function SceneElementView({ element, registry, resolveBinding }: SceneElementViewProps) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n return <>{renderElement(
|
|
1
|
+
{"version":3,"file":"SceneElementView.js","sources":["../../SceneElementView.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 { useMemo } from 'react';\nimport { applyEffectiveConfiguration, renderElement, BindingResolver } from '@cratis/scene.engine';\nimport { EffectiveConfiguration, SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry, createReactRenderer } from './renderer';\n\nexport interface SceneElementViewProps {\n element: SceneElement;\n registry: ComponentRegistry;\n resolveBinding: BindingResolver;\n\n /**\n * The resolved configuration of the template chain the element sits in, from `resolveEffectiveConfiguration`.\n * When given, each configurable component renders with its resolved properties - what a screen's own values add\n * to an inherited template. It is the same data the editor shows, and the same code path whether the screen is\n * being edited or played: there is no design-time mode.\n */\n configuration?: EffectiveConfiguration;\n}\n\n/**\n * Renders a Scene element tree with the real `Scene.React` renderer - the WYSIWYG building block Studio's\n * preview surface and Stage's shipped web bundle both consume unmodified.\n */\nexport function SceneElementView({ element, registry, resolveBinding, configuration }: SceneElementViewProps) {\n const renderer = useMemo(() => createReactRenderer(registry), [registry]);\n const configured = useMemo(() => configuration ? applyEffectiveConfiguration(element, configuration) : element, [element, configuration]);\n return <>{renderElement(configured, renderer, resolveBinding)}</>;\n}\n"],"names":["SceneElementView","element","registry","resolveBinding","configuration","renderer","useMemo","createReactRenderer","configured","applyEffectiveConfiguration","_jsx","_Fragment","renderElement"],"mappings":";;;;;;;AAsBA;;;IAIO,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,aAAa,EAAyB,EAAA;AACxG,IAAA,MAAMC,QAAAA,GAAWC,OAAAA,CAAQ,IAAMC,mBAAAA,CAAoBL,QAAAA,CAAAA,EAAW;AAACA,QAAAA;AAAS,KAAA,CAAA;AACxE,IAAA,MAAMM,aAAaF,OAAAA,CAAQ,IAAMF,gBAAgBK,2BAAAA,CAA4BR,OAAAA,EAASG,iBAAiBH,OAAAA,EAAS;AAACA,QAAAA,OAAAA;AAASG,QAAAA;AAAc,KAAA,CAAA;IACxI,qBAAOM,GAAA,CAAAC,QAAA,EAAA;AAAGC,QAAAA,QAAAA,EAAAA,aAAAA,CAAcJ,YAAYH,QAAAA,EAAUF,cAAAA;;AAClD;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreNavigationBar.d.ts","sourceRoot":"","sources":["../../../core/CoreNavigationBar.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAwBvD,wBAAgB,iBAAiB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BA4BtE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useIconAdapters } from '../icons/IconAdapterContext.js';
|
|
3
|
+
import { SceneIcon } from '../icons/SceneIcon.js';
|
|
4
|
+
|
|
5
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
6
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
7
|
+
function isNavigationBarItem(value) {
|
|
8
|
+
const candidate = value;
|
|
9
|
+
return candidate !== null && typeof candidate === 'object' && typeof candidate.id === 'string' && typeof candidate.label === 'string';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `core:navigationBar` component: a list of navigation items, the first of which a template author normally
|
|
13
|
+
* fixes as Home and the rest of which consumers of the template can add to.
|
|
14
|
+
*
|
|
15
|
+
* It reads `items` from the property bag it is given and nothing else, so it renders the same whether a screen is
|
|
16
|
+
* being played or edited - configuration is resolved into the bag before it gets here. An item names its destination
|
|
17
|
+
* as a screen, and activating it emits a host-neutral navigation event, the same as `core:navigate`. An item's icon
|
|
18
|
+
* is carried on the node as data attributes and, when an `IconAdapterProvider` is in scope, drawn through the adapter
|
|
19
|
+
* for its library; without one the item shows its label alone. Which icons exist is not this component's business.
|
|
20
|
+
*/ function CoreNavigationBar({ element }) {
|
|
21
|
+
const items = Array.isArray(element.properties.items) ? element.properties.items.filter(isNavigationBarItem) : [];
|
|
22
|
+
const adapters = useIconAdapters();
|
|
23
|
+
const title = typeof element.properties.title === 'string' ? element.properties.title : undefined;
|
|
24
|
+
return /*#__PURE__*/ jsx("nav", {
|
|
25
|
+
"data-scene-id": element.id,
|
|
26
|
+
"aria-label": title,
|
|
27
|
+
children: items.map((item)=>{
|
|
28
|
+
const targetScreen = item.destination?.screen ?? '';
|
|
29
|
+
const navigate = ()=>globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', {
|
|
30
|
+
detail: {
|
|
31
|
+
targetScreen,
|
|
32
|
+
element,
|
|
33
|
+
item
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
"data-scene-item": item.id,
|
|
39
|
+
"data-scene-icon-library": item.icon?.library,
|
|
40
|
+
"data-scene-icon-key": item.icon?.key,
|
|
41
|
+
"data-scene-icon-variant": item.icon?.variant,
|
|
42
|
+
disabled: targetScreen === '',
|
|
43
|
+
onClick: navigate,
|
|
44
|
+
children: [
|
|
45
|
+
item.icon && adapters ? /*#__PURE__*/ jsx(SceneIcon, {
|
|
46
|
+
reference: item.icon,
|
|
47
|
+
adapters: adapters
|
|
48
|
+
}) : null,
|
|
49
|
+
item.label
|
|
50
|
+
]
|
|
51
|
+
}, item.id);
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { CoreNavigationBar };
|
|
57
|
+
//# sourceMappingURL=CoreNavigationBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreNavigationBar.js","sources":["../../../core/CoreNavigationBar.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 { IconReference } from '@cratis/scene.model';\nimport { useIconAdapters } from '../icons/IconAdapterContext';\nimport { SceneIcon } from '../icons/SceneIcon';\nimport { RegisteredComponentProps } from '../renderer';\n\ninterface NavigationBarItem {\n id: string;\n label: string;\n icon?: IconReference;\n destination?: { screen: string };\n}\n\nfunction isNavigationBarItem(value: unknown): value is NavigationBarItem {\n const candidate = value as Partial<NavigationBarItem> | null;\n return candidate !== null && typeof candidate === 'object' && typeof candidate.id === 'string' && typeof candidate.label === 'string';\n}\n\n/**\n * The `core:navigationBar` component: a list of navigation items, the first of which a template author normally\n * fixes as Home and the rest of which consumers of the template can add to.\n *\n * It reads `items` from the property bag it is given and nothing else, so it renders the same whether a screen is\n * being played or edited - configuration is resolved into the bag before it gets here. An item names its destination\n * as a screen, and activating it emits a host-neutral navigation event, the same as `core:navigate`. An item's icon\n * is carried on the node as data attributes and, when an `IconAdapterProvider` is in scope, drawn through the adapter\n * for its library; without one the item shows its label alone. Which icons exist is not this component's business.\n */\nexport function CoreNavigationBar({ element }: RegisteredComponentProps) {\n const items = Array.isArray(element.properties.items) ? element.properties.items.filter(isNavigationBarItem) : [];\n const adapters = useIconAdapters();\n const title = typeof element.properties.title === 'string' ? element.properties.title : undefined;\n\n return (\n <nav data-scene-id={element.id} aria-label={title}>\n {items.map(item => {\n const targetScreen = item.destination?.screen ?? '';\n const navigate = () => globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', { detail: { targetScreen, element, item } }));\n return (\n <button\n key={item.id}\n type='button'\n data-scene-item={item.id}\n data-scene-icon-library={item.icon?.library}\n data-scene-icon-key={item.icon?.key}\n data-scene-icon-variant={item.icon?.variant}\n disabled={targetScreen === ''}\n onClick={navigate}\n >\n {item.icon && adapters ? <SceneIcon reference={item.icon} adapters={adapters} /> : null}\n {item.label}\n </button>\n );\n })}\n </nav>\n );\n}\n"],"names":["isNavigationBarItem","value","candidate","id","label","CoreNavigationBar","element","items","Array","isArray","properties","filter","adapters","useIconAdapters","title","undefined","_jsx","nav","data-scene-id","aria-label","map","item","targetScreen","destination","screen","navigate","globalThis","dispatchEvent","CustomEvent","detail","_jsxs","button","type","data-scene-item","data-scene-icon-library","icon","library","data-scene-icon-key","key","data-scene-icon-variant","variant","disabled","onClick","SceneIcon","reference"],"mappings":";;;;AAAA;AACA;AAcA,SAASA,oBAAoBC,KAAc,EAAA;AACvC,IAAA,MAAMC,SAAAA,GAAYD,KAAAA;AAClB,IAAA,OAAOC,SAAAA,KAAc,IAAA,IAAQ,OAAOA,SAAAA,KAAc,QAAA,IAAY,OAAOA,SAAAA,CAAUC,EAAE,KAAK,QAAA,IAAY,OAAOD,SAAAA,CAAUE,KAAK,KAAK,QAAA;AACjI;AAEA;;;;;;;;;AASC,IACM,SAASC,iBAAAA,CAAkB,EAAEC,OAAO,EAA4B,EAAA;AACnE,IAAA,MAAMC,QAAQC,KAAAA,CAAMC,OAAO,CAACH,OAAAA,CAAQI,UAAU,CAACH,KAAK,CAAA,GAAID,OAAAA,CAAQI,UAAU,CAACH,KAAK,CAACI,MAAM,CAACX,uBAAuB,EAAE;AACjH,IAAA,MAAMY,QAAAA,GAAWC,eAAAA,EAAAA;AACjB,IAAA,MAAMC,KAAAA,GAAQ,OAAOR,OAAAA,CAAQI,UAAU,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreComponents.d.ts","sourceRoot":"","sources":["../../../core/coreComponents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"coreComponents.d.ts","sourceRoot":"","sources":["../../../core/coreComponents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwBhD,eAAO,MAAM,cAAc,EAAE,iBAgB5B,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { componentRegistryKey } from '../packages/ScenePackageBundle.js';
|
|
|
2
2
|
import { CoreText } from './CoreText.js';
|
|
3
3
|
import { CoreButton } from './CoreButton.js';
|
|
4
4
|
import { CoreCard } from './CoreCard.js';
|
|
5
|
+
import { CoreNavigationBar } from './CoreNavigationBar.js';
|
|
5
6
|
import { CoreFile, CoreCode, CoreField, CoreSummary, CoreColumn, CoreTable, CoreTitle, CoreNavigate, CoreSection, CoreAction, CoreData } from './ScreenplayCoreComponents.js';
|
|
6
7
|
|
|
7
8
|
// Copyright (c) Cratis. All rights reserved.
|
|
@@ -23,7 +24,8 @@ import { CoreFile, CoreCode, CoreField, CoreSummary, CoreColumn, CoreTable, Core
|
|
|
23
24
|
[componentRegistryKey('core', 'summary')]: CoreSummary,
|
|
24
25
|
[componentRegistryKey('core', 'field')]: CoreField,
|
|
25
26
|
[componentRegistryKey('core', 'code')]: CoreCode,
|
|
26
|
-
[componentRegistryKey('core', 'file')]: CoreFile
|
|
27
|
+
[componentRegistryKey('core', 'file')]: CoreFile,
|
|
28
|
+
[componentRegistryKey('core', 'navigationBar')]: CoreNavigationBar
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export { coreComponents };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreComponents.js","sources":["../../../core/coreComponents.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 { ComponentRegistry } from '../renderer';\nimport { componentRegistryKey } from '../packages';\nimport { CoreText } from './CoreText';\nimport { CoreButton } from './CoreButton';\nimport { CoreCard } from './CoreCard';\nimport {\n CoreAction,\n CoreCode,\n CoreColumn,\n CoreData,\n CoreField,\n CoreFile,\n CoreNavigate,\n CoreSection,\n CoreSummary,\n CoreTable,\n CoreTitle,\n} from './ScreenplayCoreComponents';\n\n/**\n * The `core` package's component registry - the final fallback every `ui profile` resolves against\n * regardless of which other packages it lists (Scene#3).\n */\nexport const coreComponents: ComponentRegistry = {\n [componentRegistryKey('core', 'text')]: CoreText,\n [componentRegistryKey('core', 'button')]: CoreButton,\n [componentRegistryKey('core', 'card')]: CoreCard,\n [componentRegistryKey('core', 'data')]: CoreData,\n [componentRegistryKey('core', 'action')]: CoreAction,\n [componentRegistryKey('core', 'section')]: CoreSection,\n [componentRegistryKey('core', 'navigate')]: CoreNavigate,\n [componentRegistryKey('core', 'title')]: CoreTitle,\n [componentRegistryKey('core', 'table')]: CoreTable,\n [componentRegistryKey('core', 'column')]: CoreColumn,\n [componentRegistryKey('core', 'summary')]: CoreSummary,\n [componentRegistryKey('core', 'field')]: CoreField,\n [componentRegistryKey('core', 'code')]: CoreCode,\n [componentRegistryKey('core', 'file')]: CoreFile,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile"],"mappings":"
|
|
1
|
+
{"version":3,"file":"coreComponents.js","sources":["../../../core/coreComponents.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 { ComponentRegistry } from '../renderer';\nimport { componentRegistryKey } from '../packages';\nimport { CoreText } from './CoreText';\nimport { CoreButton } from './CoreButton';\nimport { CoreCard } from './CoreCard';\nimport { CoreNavigationBar } from './CoreNavigationBar';\nimport {\n CoreAction,\n CoreCode,\n CoreColumn,\n CoreData,\n CoreField,\n CoreFile,\n CoreNavigate,\n CoreSection,\n CoreSummary,\n CoreTable,\n CoreTitle,\n} from './ScreenplayCoreComponents';\n\n/**\n * The `core` package's component registry - the final fallback every `ui profile` resolves against\n * regardless of which other packages it lists (Scene#3).\n */\nexport const coreComponents: ComponentRegistry = {\n [componentRegistryKey('core', 'text')]: CoreText,\n [componentRegistryKey('core', 'button')]: CoreButton,\n [componentRegistryKey('core', 'card')]: CoreCard,\n [componentRegistryKey('core', 'data')]: CoreData,\n [componentRegistryKey('core', 'action')]: CoreAction,\n [componentRegistryKey('core', 'section')]: CoreSection,\n [componentRegistryKey('core', 'navigate')]: CoreNavigate,\n [componentRegistryKey('core', 'title')]: CoreTitle,\n [componentRegistryKey('core', 'table')]: CoreTable,\n [componentRegistryKey('core', 'column')]: CoreColumn,\n [componentRegistryKey('core', 'summary')]: CoreSummary,\n [componentRegistryKey('core', 'field')]: CoreField,\n [componentRegistryKey('core', 'code')]: CoreCode,\n [componentRegistryKey('core', 'file')]: CoreFile,\n [componentRegistryKey('core', 'navigationBar')]: CoreNavigationBar,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile","CoreNavigationBar"],"mappings":";;;;;;;AAAA;AACA;AAsBA;;;UAIaA,cAAAA,GAAoC;IAC7C,CAACC,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUC,QAAAA;IACxC,CAACD,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYE,UAAAA;IAC1C,CAACF,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUG,QAAAA;IACxC,CAACH,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUI,QAAAA;IACxC,CAACJ,oBAAAA,CAAqB,MAAA,EA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