@cratis/scene.react 4.15.0 → 4.17.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/core/ScreenplayCoreComponents.tsx +24 -3
- package/core/coreComponents.ts +2 -0
- package/core/coreDescriptors.ts +6 -0
- package/core/corePackage.ts +1 -0
- package/dist/cjs/SceneElementView.js +1 -0
- package/dist/cjs/SceneElementView.js.map +1 -1
- package/dist/cjs/core/ScreenplayCoreComponents.js +25 -5
- package/dist/cjs/core/ScreenplayCoreComponents.js.map +1 -1
- package/dist/cjs/core/coreComponents.js +3 -1
- package/dist/cjs/core/coreComponents.js.map +1 -1
- package/dist/cjs/core/coreDescriptors.js +16 -0
- package/dist/cjs/core/coreDescriptors.js.map +1 -1
- package/dist/cjs/core/corePackage.js +2 -1
- package/dist/cjs/core/corePackage.js.map +1 -1
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/CoreOutlet.js +32 -0
- package/dist/cjs/navigation/CoreOutlet.js.map +1 -0
- package/dist/cjs/navigation/SceneNavigationContext.js +2 -0
- package/dist/cjs/navigation/SceneNavigationContext.js.map +1 -1
- package/dist/cjs/navigation/SceneNavigationHost.js +46 -29
- package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/cjs/navigation/SceneOutletContext.js +14 -0
- package/dist/cjs/navigation/SceneOutletContext.js.map +1 -0
- package/dist/cjs/navigation/collectOutletOwners.js +36 -0
- package/dist/cjs/navigation/collectOutletOwners.js.map +1 -0
- package/dist/cjs/navigation/createHashSceneHistory.js +43 -0
- package/dist/cjs/navigation/createHashSceneHistory.js.map +1 -0
- package/dist/cjs/navigation/placeInOutlet.js +65 -0
- package/dist/cjs/navigation/placeInOutlet.js.map +1 -0
- package/dist/cjs/navigation/useSceneHistoryNavigation.js +22 -6
- package/dist/cjs/navigation/useSceneHistoryNavigation.js.map +1 -1
- package/dist/cjs/renderer/useValueOutput.js +31 -0
- package/dist/cjs/renderer/useValueOutput.js.map +1 -0
- package/dist/cjs/renderer/valueOutputProperty.js +28 -0
- package/dist/cjs/renderer/valueOutputProperty.js.map +1 -0
- package/dist/esm/SceneElementView.js +1 -0
- package/dist/esm/SceneElementView.js.map +1 -1
- package/dist/esm/core/ScreenplayCoreComponents.d.ts.map +1 -1
- package/dist/esm/core/ScreenplayCoreComponents.js +25 -5
- package/dist/esm/core/ScreenplayCoreComponents.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/core/coreDescriptors.js +16 -0
- package/dist/esm/core/coreDescriptors.js.map +1 -1
- package/dist/esm/core/corePackage.d.ts.map +1 -1
- package/dist/esm/core/corePackage.js +2 -1
- package/dist/esm/core/corePackage.js.map +1 -1
- package/dist/esm/index.js +8 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/CoreOutlet.d.ts +3 -0
- package/dist/esm/navigation/CoreOutlet.d.ts.map +1 -0
- package/dist/esm/navigation/CoreOutlet.js +30 -0
- package/dist/esm/navigation/CoreOutlet.js.map +1 -0
- package/dist/esm/navigation/SceneNavigationContext.d.ts +3 -0
- package/dist/esm/navigation/SceneNavigationContext.d.ts.map +1 -1
- package/dist/esm/navigation/SceneNavigationContext.js +3 -2
- package/dist/esm/navigation/SceneNavigationContext.js.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.js +47 -30
- package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/esm/navigation/SceneNavigationState.d.ts +2 -0
- package/dist/esm/navigation/SceneNavigationState.d.ts.map +1 -1
- package/dist/esm/navigation/SceneOutletContext.d.ts +9 -0
- package/dist/esm/navigation/SceneOutletContext.d.ts.map +1 -0
- package/dist/esm/navigation/SceneOutletContext.js +11 -0
- package/dist/esm/navigation/SceneOutletContext.js.map +1 -0
- package/dist/esm/navigation/collectOutletOwners.d.ts +4 -0
- package/dist/esm/navigation/collectOutletOwners.d.ts.map +1 -0
- package/dist/esm/navigation/collectOutletOwners.js +33 -0
- package/dist/esm/navigation/collectOutletOwners.js.map +1 -0
- package/dist/esm/navigation/createHashSceneHistory.d.ts +4 -0
- package/dist/esm/navigation/createHashSceneHistory.d.ts.map +1 -0
- package/dist/esm/navigation/createHashSceneHistory.js +41 -0
- package/dist/esm/navigation/createHashSceneHistory.js.map +1 -0
- package/dist/esm/navigation/index.d.ts +5 -0
- package/dist/esm/navigation/index.d.ts.map +1 -1
- package/dist/esm/navigation/index.js +5 -0
- package/dist/esm/navigation/index.js.map +1 -1
- package/dist/esm/navigation/placeInOutlet.d.ts +4 -0
- package/dist/esm/navigation/placeInOutlet.d.ts.map +1 -0
- package/dist/esm/navigation/placeInOutlet.js +63 -0
- package/dist/esm/navigation/placeInOutlet.js.map +1 -0
- package/dist/esm/navigation/useSceneHistoryNavigation.d.ts +2 -1
- package/dist/esm/navigation/useSceneHistoryNavigation.d.ts.map +1 -1
- package/dist/esm/navigation/useSceneHistoryNavigation.js +22 -6
- package/dist/esm/navigation/useSceneHistoryNavigation.js.map +1 -1
- package/dist/esm/renderer/index.d.ts +2 -0
- package/dist/esm/renderer/index.d.ts.map +1 -1
- package/dist/esm/renderer/index.js +2 -0
- package/dist/esm/renderer/index.js.map +1 -1
- package/dist/esm/renderer/useValueOutput.d.ts +4 -0
- package/dist/esm/renderer/useValueOutput.d.ts.map +1 -0
- package/dist/esm/renderer/useValueOutput.js +28 -0
- package/dist/esm/renderer/useValueOutput.js.map +1 -0
- package/dist/esm/renderer/valueOutputProperty.d.ts +3 -0
- package/dist/esm/renderer/valueOutputProperty.d.ts.map +1 -0
- package/dist/esm/renderer/valueOutputProperty.js +26 -0
- package/dist/esm/renderer/valueOutputProperty.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/navigation/CoreOutlet.tsx +26 -0
- package/navigation/SceneNavigationContext.tsx +10 -0
- package/navigation/SceneNavigationHost.tsx +12 -6
- package/navigation/SceneNavigationState.ts +13 -0
- package/navigation/SceneOutletContext.tsx +19 -0
- package/navigation/collectOutletOwners.ts +30 -0
- package/navigation/createHashSceneHistory.ts +42 -0
- package/navigation/index.ts +5 -0
- package/navigation/placeInOutlet.ts +68 -0
- package/navigation/useSceneHistoryNavigation.ts +20 -5
- package/package.json +5 -5
- package/renderer/index.ts +2 -0
- package/renderer/useValueOutput.ts +28 -0
- package/renderer/valueOutputProperty.ts +25 -0
|
@@ -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 { 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":"
|
|
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 { CoreOutlet } from '../navigation/CoreOutlet';\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 [componentRegistryKey('core', 'outlet')]: CoreOutlet,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard","CoreData","CoreAction","CoreSection","CoreNavigate","CoreTitle","CoreTable","CoreColumn","CoreSummary","CoreField","CoreCode","CoreFile","CoreNavigationBar","CoreOutlet"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAuBA;;;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,EAAQ,QAAA,CAAA,GAAYK,UAAAA;IAC1C,CAACL,oBAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaM,WAAAA;IAC3C,CAACN,oBAAAA,CAAqB,MAAA,EAAQ,UAAA,CAAA,GAAcO,YAAAA;IAC5C,CAACP,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWQ,SAAAA;IACzC,CAACR,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWS,SAAAA;IACzC,CAACT,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYU,UAAAA;IAC1C,CAACV,oBAAAA,CAAqB,MAAA,EAAQ,SAAA,CAAA,GAAaW,WAAAA;IAC3C,CAACX,oBAAAA,CAAqB,MAAA,EAAQ,OAAA,CAAA,GAAWY,SAAAA;IACzC,CAACZ,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUa,QAAAA;IACxC,CAACb,oBAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUc,QAAAA;IACxC,CAACd,oBAAAA,CAAqB,MAAA,EAAQ,eAAA,CAAA,GAAmBe,iBAAAA;IACjD,CAACf,oBAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYgB;AAC9C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreDescriptors.d.ts","sourceRoot":"","sources":["../../../core/coreDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;AAY7E,eAAO,MAAM,eAAe,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"coreDescriptors.d.ts","sourceRoot":"","sources":["../../../core/coreDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,qBAAqB,CAAC;AAY7E,eAAO,MAAM,eAAe,EAAE,mBAAmB,EAiEhD,CAAC"}
|
|
@@ -107,6 +107,22 @@ const key = (name)=>componentRegistryKey('core', name);
|
|
|
107
107
|
}
|
|
108
108
|
]
|
|
109
109
|
},
|
|
110
|
+
{
|
|
111
|
+
component: key('outlet'),
|
|
112
|
+
displayName: 'Outlet',
|
|
113
|
+
description: 'A named region another screen opens into. Placing a screen here keeps this screen on the page, and the placed screen may declare outlets of its own.',
|
|
114
|
+
properties: [
|
|
115
|
+
{
|
|
116
|
+
path: 'name',
|
|
117
|
+
label: 'Name',
|
|
118
|
+
group: 'Navigation',
|
|
119
|
+
valueType: PropertyValueType.String,
|
|
120
|
+
constraints: {
|
|
121
|
+
required: true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
},
|
|
110
126
|
{
|
|
111
127
|
component: key('navigationBar'),
|
|
112
128
|
displayName: 'Navigation bar',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.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, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey } from '../packages';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\nexport const coreDescriptors: ComponentDescriptor[] = [\n {\n component: key('button'),\n displayName: 'Button',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, default: '' },\n ],\n },\n {\n component: key('action'),\n displayName: 'Command action',\n description: 'Invokes a modeled command. The command and its argument mapping are stored on the element; the host that handles the command event reads them.',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String },\n {\n path: 'command', label: 'Command', group: 'Behavior', valueType: PropertyValueType.String,\n editorKind: 'stateChangeReference', constraints: { required: true },\n description: 'The state change this action submits.',\n },\n {\n path: 'arguments', label: 'Argument mapping', group: 'Behavior', valueType: PropertyValueType.Collection,\n description: 'Where each command argument comes from.',\n item: {\n label: 'Argument',\n properties: [\n { path: 'name', label: 'Argument', group: 'Behavior', valueType: PropertyValueType.String, constraints: { required: true } },\n { path: 'source', label: 'Source', group: 'Behavior', valueType: PropertyValueType.String, editorKind: 'bindingPath', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n {\n component: key('column'),\n displayName: 'Table column',\n properties: [\n { path: 'property', label: 'Result field', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField', constraints: { required: true } },\n { path: 'label', label: 'Heading', group: 'Content', valueType: PropertyValueType.String },\n ],\n },\n {\n component: key('navigationBar'),\n displayName: 'Navigation bar',\n description: 'A list of navigation items. A template author fixes the first item (Home) and can expose the list so that screens add their own.',\n properties: [\n { path: 'title', label: 'Title', group: 'Content', valueType: PropertyValueType.String, default: 'Navigation' },\n {\n path: 'items', label: 'Items', group: 'Content', valueType: PropertyValueType.Collection, default: [],\n item: {\n label: 'Navigation item',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, constraints: { required: true, minimumLength: 1 } },\n { path: 'icon', label: 'Icon', group: 'Content', valueType: PropertyValueType.Icon, editorKind: 'iconPicker' },\n { path: 'destination', label: 'Destination', group: 'Content', valueType: PropertyValueType.Destination, editorKind: 'screenPicker', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n];\n"],"names":["key","name","componentRegistryKey","coreDescriptors","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination"],"mappings":";;;;;;;;;AAAA;AACA;AAKA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,oBAAAA,CAAqB,MAAA,EAAQD,IAAAA,CAAAA;AAE3D;;;;;;UAOaE,eAAAA,GAAyC;AAClD,IAAA;AACIC,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,QAAA;QACbC,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,kBAAkBC,MAAM;gBAAEC,OAAAA,EAAS;AAAG;AACvG;AACL,KAAA;AACA,IAAA;AACIT,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,gBAAA;QACbS,WAAAA,EAAa,gJAAA;QACbR,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,kBAAkBC;AAAO,aAAA;AACvF,YAAA;gBACIL,IA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4BAAeC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBW,WAAW;4BAAEP,UAAAA,EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
|
|
1
|
+
{"version":3,"file":"coreDescriptors.js","sources":["../../../core/coreDescriptors.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, PropertyValueType } from '@cratis/scene.model';\nimport { componentRegistryKey } from '../packages';\n\nconst key = (name: string) => componentRegistryKey('core', name);\n\n/**\n * What can be edited on the `core` package's components.\n *\n * Only the components an author configures by hand are described: a button's label, an action's command and its\n * argument mapping, a column's heading, and the navigation bar. The Screenplay structural components - `data`,\n * `section`, `summary` - have nothing to edit that is not already a node in the tree.\n */\nexport const coreDescriptors: ComponentDescriptor[] = [\n {\n component: key('button'),\n displayName: 'Button',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, default: '' },\n ],\n },\n {\n component: key('action'),\n displayName: 'Command action',\n description: 'Invokes a modeled command. The command and its argument mapping are stored on the element; the host that handles the command event reads them.',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String },\n {\n path: 'command', label: 'Command', group: 'Behavior', valueType: PropertyValueType.String,\n editorKind: 'stateChangeReference', constraints: { required: true },\n description: 'The state change this action submits.',\n },\n {\n path: 'arguments', label: 'Argument mapping', group: 'Behavior', valueType: PropertyValueType.Collection,\n description: 'Where each command argument comes from.',\n item: {\n label: 'Argument',\n properties: [\n { path: 'name', label: 'Argument', group: 'Behavior', valueType: PropertyValueType.String, constraints: { required: true } },\n { path: 'source', label: 'Source', group: 'Behavior', valueType: PropertyValueType.String, editorKind: 'bindingPath', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n {\n component: key('column'),\n displayName: 'Table column',\n properties: [\n { path: 'property', label: 'Result field', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField', constraints: { required: true } },\n { path: 'label', label: 'Heading', group: 'Content', valueType: PropertyValueType.String },\n ],\n },\n {\n component: key('outlet'),\n displayName: 'Outlet',\n description: 'A named region another screen opens into. Placing a screen here keeps this screen on the page, and the placed screen may declare outlets of its own.',\n properties: [{ path: 'name', label: 'Name', group: 'Navigation', valueType: PropertyValueType.String, constraints: { required: true } }],\n },\n {\n component: key('navigationBar'),\n displayName: 'Navigation bar',\n description: 'A list of navigation items. A template author fixes the first item (Home) and can expose the list so that screens add their own.',\n properties: [\n { path: 'title', label: 'Title', group: 'Content', valueType: PropertyValueType.String, default: 'Navigation' },\n {\n path: 'items', label: 'Items', group: 'Content', valueType: PropertyValueType.Collection, default: [],\n item: {\n label: 'Navigation item',\n properties: [\n { path: 'label', label: 'Label', group: 'Content', valueType: PropertyValueType.String, constraints: { required: true, minimumLength: 1 } },\n { path: 'icon', label: 'Icon', group: 'Content', valueType: PropertyValueType.Icon, editorKind: 'iconPicker' },\n { path: 'destination', label: 'Destination', group: 'Content', valueType: PropertyValueType.Destination, editorKind: 'screenPicker', constraints: { required: true } },\n ],\n },\n },\n ],\n },\n];\n"],"names":["key","name","componentRegistryKey","coreDescriptors","component","displayName","properties","path","label","group","valueType","PropertyValueType","String","default","description","editorKind","constraints","required","Collection","item","minimumLength","Icon","Destination"],"mappings":";;;;;;;;;AAAA;AACA;AAKA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,oBAAAA,CAAqB,MAAA,EAAQD,IAAAA,CAAAA;AAE3D;;;;;;UAOaE,eAAAA,GAAyC;AAClD,IAAA;AACIC,QAAAA,SAAAA,EAAWJ,GAAAA,CAAI,QAAA,CAAA;QACfK,WAAAA,EAAa,QAAA;QACbC,UAAAA,EAAY;AACR,YAAA;gBAAEC,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,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EAAS;AAAa,aAAA;AAC9G,YAAA;gBACIN,IAAAA,EAAM,OAAA;gBAASC,KAAAA,EAAO,OAAA;gBAASC,KAAAA,EAAO,SAAA;AAAWC,gBAAAA,SAAAA,EAAWC,kBAAkBO,UAAU;AAAEL,gBAAAA,OAAAA,EAAS,EAAE;gBACrGM,IAAAA,EAAM;oBACFX,KAAAA,EAAO,iBAAA;oBACPF,UAAAA,EAAY;AACR,wBAAA;4BAAEC,IAAAA,EAAM,OAAA;4BAASC,KAAAA,EAAO,OAAA;4BAASC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBC,MAAM;4BAAEI,WAAAA,EAAa;gCAAEC,QAAAA,EAAU,IAAA;gCAAMG,aAAAA,EAAe;AAAE;AAAE,yBAAA;AAC1I,wBAAA;4BAAEb,IAAAA,EAAM,MAAA;4BAAQC,KAAAA,EAAO,MAAA;4BAAQC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBU,IAAI;4BAAEN,UAAAA,EAAY;AAAa,yBAAA;AAC7G,wBAAA;4BAAER,IAAAA,EAAM,aAAA;4BAAeC,KAAAA,EAAO,aAAA;4BAAeC,KAAAA,EAAO,SAAA;AAAWC,4BAAAA,SAAAA,EAAWC,kBAAkBW,WAAW;4BAAEP,UAAAA,EAAY,cAAA;4BAAgBC,WAAAA,EAAa;gCAAEC,QAAAA,EAAU;AAAK;AAAE;AACxK;AACL;AACJ;AACH;AACL;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corePackage.d.ts","sourceRoot":"","sources":["../../../core/corePackage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWjD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"corePackage.d.ts","sourceRoot":"","sources":["../../../core/corePackage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWjD,eAAO,MAAM,mBAAmB,EAAE,YAgCjC,CAAC;AAKF,eAAO,MAAM,WAAW,EAAE,kBAIzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corePackage.js","sources":["../../../core/corePackage.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 '../packages';\nimport { coreComponents } from './coreComponents';\nimport { coreDescriptors } from './coreDescriptors';\n\n/**\n * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;\n * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to\n * resolve regardless of which packages a profile lists. It is still declared the same way as any other -\n * a package picker should be able to show it, and the dependency resolver should be able to reason about\n * it, without a special case.\n */\nexport const corePackageManifest: ScenePackage = {\n name: 'core',\n version: '1.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [],\n components: [\n 'text',\n 'button',\n 'card',\n 'data',\n 'action',\n 'section',\n 'navigate',\n 'title',\n 'table',\n 'column',\n 'summary',\n 'field',\n 'code',\n 'file',\n 'navigationBar',\n ],\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n themes: [],\n displayName: 'Core',\n description: 'The built-in fallback vocabulary every ui profile resolves against.',\n module: '@cratis/scene.react',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `core` package as a loadable bundle.\n */\nexport const corePackage: ScenePackageBundle = {\n manifest: corePackageManifest,\n components: coreComponents,\n descriptors: coreDescriptors,\n};\n"],"names":["corePackageManifest","name","version","kind","PackageKind","ComponentLibrary","dependencies","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","corePackage","manifest","coreComponents","descriptors","coreDescriptors"],"mappings":";;;;AAAA;AACA;AAOA;;;;;;UAOaA,mBAAAA,GAAoC;IAC7CC,IAAAA,EAAM,MAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,YAAYC,gBAAgB;AAClCC,IAAAA,YAAAA,EAAc,EAAE;IAChBC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,MAAA;AACA,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,OAAA;AACA,QAAA,OAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,OAAA;AACA,QAAA,MAAA;AACA,QAAA,MAAA;AACA,QAAA;AACH,KAAA;AACDC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,MAAAA,EAAQ,EAAE;IACVC,WAAAA,EAAa,MAAA;IACbC,WAAAA,EAAa,qEAAA;IACbC,MAAAA,EAAQ,qBAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;UAGaC,WAAAA,GAAkC;IAC3CC,QAAAA,EAAUlB,mBAAAA;IACVO,UAAAA,EAAYY,cAAAA;IACZC,WAAAA,EAAaC;AACjB;;"}
|
|
1
|
+
{"version":3,"file":"corePackage.js","sources":["../../../core/corePackage.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 '../packages';\nimport { coreComponents } from './coreComponents';\nimport { coreDescriptors } from './coreDescriptors';\n\n/**\n * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;\n * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to\n * resolve regardless of which packages a profile lists. It is still declared the same way as any other -\n * a package picker should be able to show it, and the dependency resolver should be able to reason about\n * it, without a special case.\n */\nexport const corePackageManifest: ScenePackage = {\n name: 'core',\n version: '1.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [],\n components: [\n 'text',\n 'button',\n 'card',\n 'data',\n 'action',\n 'section',\n 'navigate',\n 'title',\n 'table',\n 'column',\n 'summary',\n 'field',\n 'code',\n 'file',\n 'navigationBar',\n 'outlet',\n ],\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n themes: [],\n displayName: 'Core',\n description: 'The built-in fallback vocabulary every ui profile resolves against.',\n module: '@cratis/scene.react',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `core` package as a loadable bundle.\n */\nexport const corePackage: ScenePackageBundle = {\n manifest: corePackageManifest,\n components: coreComponents,\n descriptors: coreDescriptors,\n};\n"],"names":["corePackageManifest","name","version","kind","PackageKind","ComponentLibrary","dependencies","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","corePackage","manifest","coreComponents","descriptors","coreDescriptors"],"mappings":";;;;AAAA;AACA;AAOA;;;;;;UAOaA,mBAAAA,GAAoC;IAC7CC,IAAAA,EAAM,MAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,YAAYC,gBAAgB;AAClCC,IAAAA,YAAAA,EAAc,EAAE;IAChBC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,MAAA;AACA,QAAA,MAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,OAAA;AACA,QAAA,OAAA;AACA,QAAA,QAAA;AACA,QAAA,SAAA;AACA,QAAA,OAAA;AACA,QAAA,MAAA;AACA,QAAA,MAAA;AACA,QAAA,eAAA;AACA,QAAA;AACH,KAAA;AACDC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,MAAAA,EAAQ,EAAE;IACVC,WAAAA,EAAa,MAAA;IACbC,WAAAA,EAAa,qEAAA;IACbC,MAAAA,EAAQ,qBAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;UAGaC,WAAAA,GAAkC;IAC3CC,QAAAA,EAAUlB,mBAAAA;IACVO,UAAAA,EAAYY,cAAAA;IACZC,WAAAA,EAAaC;AACjB;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { BindingOutputProvider, useBindingOutputScope, useBindingOutputs } from
|
|
|
4
4
|
export { RenderBindingScopeProvider, useRenderBindingResolver, useRenderBindingScope } from './renderer/RenderBindingScopeContext.js';
|
|
5
5
|
export { UnresolvedComponent } from './renderer/UnresolvedComponent.js';
|
|
6
6
|
export { useBoundQuery } from './renderer/useBoundQuery.js';
|
|
7
|
+
export { useValueOutput, valueOutputName } from './renderer/useValueOutput.js';
|
|
8
|
+
export { valueOutputProperty } from './renderer/valueOutputProperty.js';
|
|
7
9
|
export { createReactRenderer } from './renderer/createReactRenderer.js';
|
|
8
10
|
export { InteractiveComponent } from './renderer/InteractiveComponent.js';
|
|
9
11
|
export { CoreText } from './core/CoreText.js';
|
|
@@ -16,9 +18,10 @@ export { coreComponents } from './core/coreComponents.js';
|
|
|
16
18
|
export { corePackage, corePackageManifest } from './core/corePackage.js';
|
|
17
19
|
export { NavBar } from './NavBar/NavBar.js';
|
|
18
20
|
export { extractNavigationItem } from './NavBar/extractNavigationItem.js';
|
|
19
|
-
export { SceneNavigationProvider, useSceneNavigation } from './navigation/SceneNavigationContext.js';
|
|
21
|
+
export { SceneNavigationContextInternal, SceneNavigationProvider, useSceneNavigation } from './navigation/SceneNavigationContext.js';
|
|
20
22
|
export { SceneNavigationHost } from './navigation/SceneNavigationHost.js';
|
|
21
23
|
export { createBrowserSceneHistory } from './navigation/createBrowserSceneHistory.js';
|
|
24
|
+
export { createHashSceneHistory } from './navigation/createHashSceneHistory.js';
|
|
22
25
|
export { createMemorySceneHistory } from './navigation/createMemorySceneHistory.js';
|
|
23
26
|
export { diagnoseRenderedNavigation } from './navigation/diagnoseRenderedNavigation.js';
|
|
24
27
|
export { identityRoute } from './navigation/identityRoute.js';
|
|
@@ -27,6 +30,10 @@ export { navigationRouteKey } from './navigation/navigationRouteKey.js';
|
|
|
27
30
|
export { resolveDestination } from './navigation/resolveDestination.js';
|
|
28
31
|
export { sceneRoutesFrom } from './navigation/sceneRoutesFrom.js';
|
|
29
32
|
export { useSceneHistoryNavigation } from './navigation/useSceneHistoryNavigation.js';
|
|
33
|
+
export { CoreOutlet } from './navigation/CoreOutlet.js';
|
|
34
|
+
export { SceneOutletContext, useSceneOutlets } from './navigation/SceneOutletContext.js';
|
|
35
|
+
export { collectOutletOwners, outletComponentName } from './navigation/collectOutletOwners.js';
|
|
36
|
+
export { placeInOutlet } from './navigation/placeInOutlet.js';
|
|
30
37
|
export { IconAdapterRegistry, createIconAdapterRegistry } from './icons/IconAdapterRegistry.js';
|
|
31
38
|
export { IconAdapterProvider, useIconAdapters } from './icons/IconAdapterContext.js';
|
|
32
39
|
export { useIconGlyph } from './icons/useIconGlyph.js';
|
package/dist/esm/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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreOutlet.d.ts","sourceRoot":"","sources":["../../../navigation/CoreOutlet.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAUzE,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAW/D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { SceneElementView } from '../SceneElementView.js';
|
|
4
|
+
import { SceneNavigationContextInternal } from './SceneNavigationContext.js';
|
|
5
|
+
import { useSceneOutlets } from './SceneOutletContext.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A nested outlet a screen declares: `core:outlet` with a `name`. Inside a navigation host it renders the
|
|
9
|
+
* screen placed in that outlet - which may declare outlets of its own, so composition nests to any depth -
|
|
10
|
+
* and nothing while the outlet is empty. Outside a navigation host it renders the empty region.
|
|
11
|
+
*/ function CoreOutlet({ element }) {
|
|
12
|
+
const name = typeof element.properties.name === 'string' ? element.properties.name : '';
|
|
13
|
+
const navigation = useContext(SceneNavigationContextInternal);
|
|
14
|
+
const outlets = useSceneOutlets();
|
|
15
|
+
const placed = navigation?.outlets[name];
|
|
16
|
+
const screen = placed && outlets ? outlets.screens[placed] : undefined;
|
|
17
|
+
return /*#__PURE__*/ jsx("div", {
|
|
18
|
+
"data-scene-outlet": name,
|
|
19
|
+
"data-scene-outlet-screen": placed,
|
|
20
|
+
children: screen && outlets && /*#__PURE__*/ jsx(SceneElementView, {
|
|
21
|
+
element: screen,
|
|
22
|
+
registry: outlets.registry,
|
|
23
|
+
dataContext: navigation?.bindingScope.dataContext,
|
|
24
|
+
queryResults: navigation?.bindingScope.queryResults
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { CoreOutlet };
|
|
30
|
+
//# sourceMappingURL=CoreOutlet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreOutlet.js","sources":["../../../navigation/CoreOutlet.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 { useContext } from 'react';\nimport { RegisteredComponentProps } from '../renderer/ComponentRegistry';\nimport { SceneElementView } from '../SceneElementView';\nimport { SceneNavigationContextInternal } from './SceneNavigationContext';\nimport { useSceneOutlets } from './SceneOutletContext';\n\n/**\n * A nested outlet a screen declares: `core:outlet` with a `name`. Inside a navigation host it renders the\n * screen placed in that outlet - which may declare outlets of its own, so composition nests to any depth -\n * and nothing while the outlet is empty. Outside a navigation host it renders the empty region.\n */\nexport function CoreOutlet({ element }: RegisteredComponentProps) {\n const name = typeof element.properties.name === 'string' ? element.properties.name : '';\n const navigation = useContext(SceneNavigationContextInternal);\n const outlets = useSceneOutlets();\n const placed = navigation?.outlets[name];\n const screen = placed && outlets ? outlets.screens[placed] : undefined;\n\n return <div data-scene-outlet={name} data-scene-outlet-screen={placed}>\n {screen && outlets && <SceneElementView element={screen} registry={outlets.registry}\n dataContext={navigation?.bindingScope.dataContext} queryResults={navigation?.bindingScope.queryResults} />}\n </div>;\n}\n"],"names":["CoreOutlet","element","name","properties","navigation","useContext","SceneNavigationContextInternal","outlets","useSceneOutlets","placed","screen","screens","undefined","_jsx","div","data-scene-outlet","data-scene-outlet-screen","SceneElementView","registry","dataContext","bindingScope","queryResults"],"mappings":";;;;;;AASA;;;;AAIC,IACM,SAASA,UAAAA,CAAW,EAAEC,OAAO,EAA4B,EAAA;AAC5D,IAAA,MAAMC,IAAAA,GAAO,OAAOD,OAAAA,CAAQE,UAAU,CAACD,IAAI,KAAK,QAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACD,IAAI,GAAG,EAAA;AACrF,IAAA,MAAME,aAAaC,UAAAA,CAAWC,8BAAAA,CAAAA;AAC9B,IAAA,MAAMC,OAAAA,GAAUC,eAAAA,EAAAA;AAChB,IAAA,MAAMC,MAAAA,GAASL,UAAAA,EAAYG,OAAO,CAACL,IAAAA,CAAK;AACxC,IAAA,MAAMQ,SAASD,MAAAA,IAAUF,OAAAA,GAAUA,QAAQI,OAAO,CAACF,OAAO,GAAGG,SAAAA;AAE7D,IAAA,qBAAOC,GAAA,CAACC,KAAAA,EAAAA;QAAIC,mBAAAA,EAAmBb,IAAAA;QAAMc,0BAAAA,EAA0BP,MAAAA;AAC1DC,QAAAA,QAAAA,EAAAA,MAAAA,IAAUH,yBAAWM,GAAA,CAACI,gBAAAA,EAAAA;YAAiBhB,OAAAA,EAASS,MAAAA;AAAQQ,YAAAA,QAAAA,EAAUX,QAAQW,QAAQ;AAC/EC,YAAAA,WAAAA,EAAaf,YAAYgB,YAAAA,CAAaD,WAAAA;AAAaE,YAAAA,YAAAA,EAAcjB,YAAYgB,YAAAA,CAAaC;;;AAEtG;;"}
|
|
@@ -5,6 +5,8 @@ import { DestinationResolution } from './DestinationResolution';
|
|
|
5
5
|
import { DialogResult } from './DialogResult';
|
|
6
6
|
export interface SceneNavigationContextValue {
|
|
7
7
|
currentScreen: string;
|
|
8
|
+
primaryScreen: string;
|
|
9
|
+
outlets: Record<string, string>;
|
|
8
10
|
currentUrl?: string;
|
|
9
11
|
currentOutlet?: string;
|
|
10
12
|
currentDialog?: string;
|
|
@@ -16,6 +18,7 @@ export interface SceneNavigationContextValue {
|
|
|
16
18
|
closeDialog(result?: unknown): void;
|
|
17
19
|
back(): void;
|
|
18
20
|
}
|
|
21
|
+
export declare const SceneNavigationContextInternal: import("react").Context<SceneNavigationContextValue | undefined>;
|
|
19
22
|
export interface SceneNavigationProviderProps {
|
|
20
23
|
value: SceneNavigationContextValue;
|
|
21
24
|
children: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationContext.d.ts","sourceRoot":"","sources":["../../../navigation/SceneNavigationContext.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OA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EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,4BAA4B,+BAExF;AAED,wBAAgB,kBAAkB,IAAI,2BAA2B,CAIhE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
3
|
|
|
4
4
|
const Context = /*#__PURE__*/ createContext(undefined);
|
|
5
|
+
/** The navigation context itself, for components that render outside a host as well as inside one. */ const SceneNavigationContextInternal = Context;
|
|
5
6
|
function SceneNavigationProvider({ value, children }) {
|
|
6
7
|
return /*#__PURE__*/ jsx(Context.Provider, {
|
|
7
8
|
value: value,
|
|
@@ -14,5 +15,5 @@ function useSceneNavigation() {
|
|
|
14
15
|
return context;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export { SceneNavigationProvider, useSceneNavigation };
|
|
18
|
+
export { SceneNavigationContextInternal, SceneNavigationProvider, useSceneNavigation };
|
|
18
19
|
//# sourceMappingURL=SceneNavigationContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.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, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { DialogResult } from './DialogResult';\n\nexport interface SceneNavigationContextValue {\n currentScreen: string;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n\n /** The route parameters of the current entry - from the destination that opened it, or the deep link. */\n currentParameters: Record<string, string>;\n\n /** What the last dialog returned when it closed. */\n dialogResult?: DialogResult;\n\n /** A deep link that matched no route; the host fell back to its initial screen. */\n unresolvedUrl?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n\n /** Closes the open dialog, returning to the entry that opened it, and records its result. */\n closeDialog(result?: unknown): void;\n\n /** Goes back one history entry. */\n back(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.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, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { DialogResult } from './DialogResult';\n\nexport interface SceneNavigationContextValue {\n /** The screen the last navigation opened. */\n currentScreen: string;\n\n /** The screen in the primary region. */\n primaryScreen: string;\n\n /** Which screen each nested outlet shows, by outlet name. */\n outlets: Record<string, string>;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n\n /** The route parameters of the current entry - from the destination that opened it, or the deep link. */\n currentParameters: Record<string, string>;\n\n /** What the last dialog returned when it closed. */\n dialogResult?: DialogResult;\n\n /** A deep link that matched no route; the host fell back to its initial screen. */\n unresolvedUrl?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n\n /** Closes the open dialog, returning to the entry that opened it, and records its result. */\n closeDialog(result?: unknown): void;\n\n /** Goes back one history entry. */\n back(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\n/** The navigation context itself, for components that render outside a host as well as inside one. */\nexport const SceneNavigationContextInternal = Context;\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationContextInternal","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;AAwCA,MAAMA,wBAAUC,aAAAA,CAAuDC,SAAAA,CAAAA;AAEvE,uGACO,MAAMC,8BAAAA,GAAiCH;AAOvC,SAASI,uBAAAA,CAAwB,EAAEC,KAAK,EAAEC,QAAQ,EAAgC,EAAA;IACrF,qBAAOC,GAAA,CAACP,QAAQQ,QAAQ,EAAA;QAACH,KAAAA,EAAOA,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEO,SAASG,kBAAAA,GAAAA;AACZ,IAAA,MAAMC,UAAUC,UAAAA,CAAWX,OAAAA,CAAAA;AAC3B,IAAA,IAAI,CAACU,OAAAA,EAAS,MAAM,IAAIE,KAAAA,CAAM,2CAAA,CAAA;IAC9B,OAAOF,OAAAA;AACX;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationHost.d.ts","sourceRoot":"","sources":["../../../navigation/SceneNavigationHost.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SceneNavigationHost.d.ts","sourceRoot":"","sources":["../../../navigation/SceneNavigationHost.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,MAAM,WAAW,wBAAwB;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,YAAY,CAAC,EAAE,YAAY,CAAC;IAM5B,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAGtC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AASD,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,OAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAiB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,wBAAwB,+BAkBjK"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useMemo } from 'react';
|
|
3
3
|
import { SceneElementView } from '../SceneElementView.js';
|
|
4
4
|
import { createMemorySceneHistory } from './createMemorySceneHistory.js';
|
|
5
5
|
import { SceneNavigationProvider } from './SceneNavigationContext.js';
|
|
6
6
|
import { sceneRoutesFrom } from './sceneRoutesFrom.js';
|
|
7
|
+
import { collectOutletOwners } from './collectOutletOwners.js';
|
|
8
|
+
import { SceneOutletContext } from './SceneOutletContext.js';
|
|
7
9
|
import { useSceneHistoryNavigation } from './useSceneHistoryNavigation.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
* Executes Scene destinations against an in-memory rendered hierarchy:
|
|
12
|
+
* Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -
|
|
13
|
+
* one a screen declares with `core:outlet` - places its screen there and keeps the screens above it, to any
|
|
14
|
+
* depth; any other screen route replaces the primary region,
|
|
11
15
|
* dialog destinations render dialog content over the screen that opened them, and external destinations
|
|
12
16
|
* only report their resolved action. Every navigation is a history entry.
|
|
13
17
|
*/ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }) {
|
|
@@ -17,37 +21,50 @@ import { useSceneHistoryNavigation } from './useSceneHistoryNavigation.js';
|
|
|
17
21
|
routes,
|
|
18
22
|
screens
|
|
19
23
|
]);
|
|
20
|
-
const
|
|
21
|
-
|
|
24
|
+
const outletOwners = useMemo(()=>collectOutletOwners(screens), [
|
|
25
|
+
screens
|
|
26
|
+
]);
|
|
27
|
+
const value = useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope, outletOwners, destinations);
|
|
28
|
+
const outletContext = useMemo(()=>({
|
|
29
|
+
screens,
|
|
30
|
+
registry
|
|
31
|
+
}), [
|
|
32
|
+
registry,
|
|
33
|
+
screens
|
|
34
|
+
]);
|
|
35
|
+
const screen = screens[value.primaryScreen];
|
|
22
36
|
const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;
|
|
23
|
-
return /*#__PURE__*/
|
|
37
|
+
return /*#__PURE__*/ jsx(SceneNavigationProvider, {
|
|
24
38
|
value: value,
|
|
25
|
-
children:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
children: /*#__PURE__*/ jsxs(SceneOutletContext.Provider, {
|
|
40
|
+
value: outletContext,
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ jsx("div", {
|
|
43
|
+
"data-scene-outlet": value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary',
|
|
44
|
+
"data-scene-url": value.currentUrl,
|
|
45
|
+
children: screen && /*#__PURE__*/ jsx(SceneElementView, {
|
|
46
|
+
element: screen,
|
|
47
|
+
registry: registry,
|
|
48
|
+
dataContext: bindingScope.dataContext,
|
|
49
|
+
queryResults: bindingScope.queryResults,
|
|
50
|
+
componentOutputs: bindingScope.componentOutputs
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
dialog && /*#__PURE__*/ jsx("div", {
|
|
54
|
+
role: "dialog",
|
|
55
|
+
"aria-modal": "true",
|
|
56
|
+
"aria-label": value.currentDialog,
|
|
57
|
+
"data-scene-dialog": value.currentDialog,
|
|
58
|
+
children: /*#__PURE__*/ jsx(SceneElementView, {
|
|
59
|
+
element: dialog,
|
|
60
|
+
registry: registry,
|
|
61
|
+
dataContext: bindingScope.dataContext,
|
|
62
|
+
queryResults: bindingScope.queryResults,
|
|
63
|
+
componentOutputs: bindingScope.componentOutputs
|
|
64
|
+
})
|
|
48
65
|
})
|
|
49
|
-
|
|
50
|
-
|
|
66
|
+
]
|
|
67
|
+
})
|
|
51
68
|
});
|
|
52
69
|
}
|
|
53
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.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, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference, SceneElement } from '@cratis/scene.model';\nimport { SceneElementView } from '../SceneElementView';\nimport { ComponentRegistry } from '../renderer';\nimport { createMemorySceneHistory } from './createMemorySceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationProvider } from './SceneNavigationContext';\nimport { SceneRoute } from './SceneRoute';\nimport { sceneRoutesFrom } from './sceneRoutesFrom';\nimport { useSceneHistoryNavigation } from './useSceneHistoryNavigation';\n\nexport interface SceneNavigationHostProps {\n screens: Record<string, SceneElement>;\n dialogs?: Record<string, SceneElement>;\n initialScreen: string;\n registry: ComponentRegistry;\n bindingScope?: BindingScope;\n\n /**\n * Where entries are recorded. `createBrowserSceneHistory()` drives the address bar, so deep links,\n * refresh and back/forward work; the default is an in-memory history for embedded hosts.\n */\n history?: SceneHistory;\n\n /** The destinations the application navigates to, so their route overrides can be deep linked. */\n destinations?: DestinationReference[];\n\n /** An explicit route table, used instead of the one derived from `screens` and `destinations`. */\n routes?: SceneRoute[];\n}\n\n/**\n * Executes Scene destinations against an in-memory rendered hierarchy: screen
|
|
1
|
+
{"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.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, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference, SceneElement } from '@cratis/scene.model';\nimport { SceneElementView } from '../SceneElementView';\nimport { ComponentRegistry } from '../renderer';\nimport { createMemorySceneHistory } from './createMemorySceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationProvider } from './SceneNavigationContext';\nimport { SceneRoute } from './SceneRoute';\nimport { sceneRoutesFrom } from './sceneRoutesFrom';\nimport { collectOutletOwners } from './collectOutletOwners';\nimport { SceneOutletContext } from './SceneOutletContext';\nimport { useSceneHistoryNavigation } from './useSceneHistoryNavigation';\n\nexport interface SceneNavigationHostProps {\n screens: Record<string, SceneElement>;\n dialogs?: Record<string, SceneElement>;\n initialScreen: string;\n registry: ComponentRegistry;\n bindingScope?: BindingScope;\n\n /**\n * Where entries are recorded. `createBrowserSceneHistory()` drives the address bar, so deep links,\n * refresh and back/forward work; the default is an in-memory history for embedded hosts.\n */\n history?: SceneHistory;\n\n /** The destinations the application navigates to, so their route overrides can be deep linked. */\n destinations?: DestinationReference[];\n\n /** An explicit route table, used instead of the one derived from `screens` and `destinations`. */\n routes?: SceneRoute[];\n}\n\n/**\n * Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -\n * one a screen declares with `core:outlet` - places its screen there and keeps the screens above it, to any\n * depth; any other screen route replaces the primary region,\n * dialog destinations render dialog content over the screen that opened them, and external destinations\n * only report their resolved action. Every navigation is a history entry.\n */\nexport function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }: SceneNavigationHostProps) {\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const routeTable = useMemo(() => routes ?? sceneRoutesFrom(Object.keys(screens), destinations), [destinations, routes, screens]);\n const outletOwners = useMemo(() => collectOutletOwners(screens), [screens]);\n const value = useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope, outletOwners, destinations);\n const outletContext = useMemo(() => ({ screens, registry }), [registry, screens]);\n\n const screen = screens[value.primaryScreen];\n const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;\n\n return <SceneNavigationProvider value={value}><SceneOutletContext.Provider value={outletContext}>\n <div data-scene-outlet={value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary'} data-scene-url={value.currentUrl}>\n {screen && <SceneElementView element={screen} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />}\n </div>\n {dialog && <div role='dialog' aria-modal='true' aria-label={value.currentDialog} data-scene-dialog={value.currentDialog}>\n <SceneElementView element={dialog} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />\n </div>}\n </SceneOutletContext.Provider></SceneNavigationProvider>;\n}\n"],"names":["SceneNavigationHost","screens","dialogs","initialScreen","registry","bindingScope","history","destinations","routes","memoryHistory","useState","createMemorySceneHistory","routeTable","useMemo","sceneRoutesFrom","Object","keys","outletOwners","collectOutletOwners","value","useSceneHistoryNavigation","outletContext","screen","primaryScreen","dialog","currentDialog","undefined","_jsx","SceneNavigationProvider","_jsxs","SceneOutletContext","Provider","div","data-scene-outlet","currentScreen","currentOutlet","data-scene-url","currentUrl","SceneElementView","element","dataContext","queryResults","componentOutputs","role","aria-modal","aria-label","data-scene-dialog"],"mappings":";;;;;;;;;;AAqCA;;;;;;IAOO,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAAEC,OAAAA,GAAU,EAAE,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,YAAAA,GAAe,EAAE,EAAEC,OAAO,EAAEC,YAAY,EAAEC,MAAM,EAA4B,EAAA;AAC9J,IAAA,MAAM,CAACC,aAAAA,CAAc,GAAGC,QAAAA,CAAS,IAAMC,wBAAAA,EAAAA,CAAAA;IACvC,MAAMC,UAAAA,GAAaC,QAAQ,IAAML,MAAAA,IAAUM,gBAAgBC,MAAAA,CAAOC,IAAI,CAACf,OAAAA,CAAAA,EAAUM,YAAAA,CAAAA,EAAe;AAACA,QAAAA,YAAAA;AAAcC,QAAAA,MAAAA;AAAQP,QAAAA;AAAQ,KAAA,CAAA;AAC/H,IAAA,MAAMgB,YAAAA,GAAeJ,OAAAA,CAAQ,IAAMK,mBAAAA,CAAoBjB,OAAAA,CAAAA,EAAU;AAACA,QAAAA;AAAQ,KAAA,CAAA;AAC1E,IAAA,MAAMkB,QAAQC,yBAAAA,CAA0Bd,OAAAA,IAAWG,eAAeG,UAAAA,EAAYT,aAAAA,EAAeE,cAAcY,YAAAA,EAAcV,YAAAA,CAAAA;IACzH,MAAM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AAiBC,OAAAA,EAASf,MAAAA;wBAAQpB,QAAAA,EAAUA,QAAAA;AAAUoC,wBAAAA,WAAAA,EAAanC,aAAamC,WAAW;AAAEC,wBAAAA,YAAAA,EAAcpC,aAAaoC,YAAY;AAAEC,wBAAAA,gBAAAA,EAAkBrC,aAAaqC;;;;;;AAGlL;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneNavigationState.d.ts","sourceRoot":"","sources":["../../../navigation/SceneNavigationState.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,oBAAoB;
|
|
1
|
+
{"version":3,"file":"SceneNavigationState.d.ts","sourceRoot":"","sources":["../../../navigation/SceneNavigationState.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,oBAAoB;IAEjC,MAAM,EAAE,MAAM,CAAC;IAMf,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAGjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SceneElement } from '@cratis/scene.model';
|
|
2
|
+
import { ComponentRegistry } from '../renderer';
|
|
3
|
+
export interface SceneOutletContextValue {
|
|
4
|
+
screens: Record<string, SceneElement>;
|
|
5
|
+
registry: ComponentRegistry;
|
|
6
|
+
}
|
|
7
|
+
export declare const SceneOutletContext: import("react").Context<SceneOutletContextValue | undefined>;
|
|
8
|
+
export declare function useSceneOutlets(): SceneOutletContextValue | undefined;
|
|
9
|
+
//# sourceMappingURL=SceneOutletContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneOutletContext.d.ts","sourceRoot":"","sources":["../../../navigation/SceneOutletContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,QAAQ,EAAE,iBAAiB,CAAC;CAC/B;AAED,eAAO,MAAM,kBAAkB,8DAAgE,CAAC;AAGhG,wBAAgB,eAAe,IAAI,uBAAuB,GAAG,SAAS,CAErE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
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
|
+
const SceneOutletContext = /*#__PURE__*/ createContext(undefined);
|
|
6
|
+
/** The screens and registry of the enclosing navigation host, or undefined outside one. */ function useSceneOutlets() {
|
|
7
|
+
return useContext(SceneOutletContext);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SceneOutletContext, useSceneOutlets };
|
|
11
|
+
//# sourceMappingURL=SceneOutletContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneOutletContext.js","sources":["../../../navigation/SceneOutletContext.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 { createContext, useContext } from 'react';\nimport { SceneElement } from '@cratis/scene.model';\nimport { ComponentRegistry } from '../renderer';\n\n/** What a nested outlet needs to render the screen placed in it. */\nexport interface SceneOutletContextValue {\n screens: Record<string, SceneElement>;\n registry: ComponentRegistry;\n}\n\nexport const SceneOutletContext = createContext<SceneOutletContextValue | undefined>(undefined);\n\n/** The screens and registry of the enclosing navigation host, or undefined outside one. */\nexport function useSceneOutlets(): SceneOutletContextValue | undefined {\n return useContext(SceneOutletContext);\n}\n"],"names":["SceneOutletContext","createContext","undefined","useSceneOutlets","useContext"],"mappings":";;AAAA;AACA;AAYO,MAAMA,kBAAAA,iBAAqBC,aAAAA,CAAmDC,SAAAA;AAErF,4FACO,SAASC,eAAAA,GAAAA;AACZ,IAAA,OAAOC,UAAAA,CAAWJ,kBAAAA,CAAAA;AACtB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectOutletOwners.d.ts","sourceRoot":"","sources":["../../../navigation/collectOutletOwners.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAOjD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASjG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
/** The registry key of the component that declares a nested outlet. */ const outletComponentName = 'core:outlet';
|
|
4
|
+
/**
|
|
5
|
+
* Which screen declares each nested outlet: every `core:outlet` element, by its `name`, mapped to the screen
|
|
6
|
+
* whose tree contains it. A screen that declares an outlet another screen also declares keeps the first one,
|
|
7
|
+
* in screen order - the same rule navigation diagnostics report as a duplicate outlet.
|
|
8
|
+
*/ function collectOutletOwners(screens) {
|
|
9
|
+
const owners = {};
|
|
10
|
+
for (const [screen, element] of Object.entries(screens)){
|
|
11
|
+
for (const outlet of outletNames(element)){
|
|
12
|
+
if (!(outlet in owners)) owners[outlet] = screen;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return owners;
|
|
16
|
+
}
|
|
17
|
+
function outletNames(element) {
|
|
18
|
+
const node = element;
|
|
19
|
+
const own = node.componentName === outletComponentName && typeof node.properties?.name === 'string' ? [
|
|
20
|
+
node.properties.name
|
|
21
|
+
] : [];
|
|
22
|
+
const children = [
|
|
23
|
+
...Object.values(node.slots ?? {}).flat(),
|
|
24
|
+
...Array.isArray(node.children) ? node.children : []
|
|
25
|
+
];
|
|
26
|
+
return [
|
|
27
|
+
...own,
|
|
28
|
+
...children.flatMap(outletNames)
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { collectOutletOwners, outletComponentName };
|
|
33
|
+
//# sourceMappingURL=collectOutletOwners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectOutletOwners.js","sources":["../../../navigation/collectOutletOwners.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 { SceneElement } from '@cratis/scene.model';\n\n/** The registry key of the component that declares a nested outlet. */\nexport const outletComponentName = 'core:outlet';\n\n/**\n * Which screen declares each nested outlet: every `core:outlet` element, by its `name`, mapped to the screen\n * whose tree contains it. A screen that declares an outlet another screen also declares keeps the first one,\n * in screen order - the same rule navigation diagnostics report as a duplicate outlet.\n */\nexport function collectOutletOwners(screens: Record<string, SceneElement>): Record<string, string> {\n const owners: Record<string, string> = {};\n for (const [screen, element] of Object.entries(screens)) {\n for (const outlet of outletNames(element)) {\n if (!(outlet in owners)) owners[outlet] = screen;\n }\n }\n\n return owners;\n}\n\nfunction outletNames(element: SceneElement): string[] {\n const node = element as { componentName?: string; properties?: Record<string, unknown>; slots?: Record<string, SceneElement[]>; children?: SceneElement[] };\n const own = node.componentName === outletComponentName && typeof node.properties?.name === 'string' ? [node.properties.name] : [];\n const children = [...Object.values(node.slots ?? {}).flat(), ...(Array.isArray(node.children) ? node.children : [])];\n return [...own, ...children.flatMap(outletNames)];\n}\n"],"names":["outletComponentName","collectOutletOwners","screens","owners","screen","element","Object","entries","outlet","outletNames","node","own","componentName","properties","name","children","values","slots","flat","Array","isArray","flatMap"],"mappings":"AAAA;AACA;AAIA,wEACO,MAAMA,mB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AgB,CAAC;AAY9C,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,kBAA2B,GAAG,YAAY,CAyBzF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
const stateKey = 'sceneNavigation';
|
|
4
|
+
/**
|
|
5
|
+
* A history kept in the URL fragment - `index.html#/WorkItemDetails?workItemId=B` - for hosts that are served
|
|
6
|
+
* as a single file or from a path they do not control, such as a generated runtime or a webview. It behaves
|
|
7
|
+
* like `createBrowserSceneHistory`: entries are pushed with their navigation state, back and forward restore
|
|
8
|
+
* them, and a typed or bookmarked fragment is matched by URL alone. A fragment changed by hand, which fires
|
|
9
|
+
* `hashchange` rather than `popstate`, is reported the same way.
|
|
10
|
+
*/ function createHashSceneHistory(browser = window) {
|
|
11
|
+
const location = ()=>{
|
|
12
|
+
const fragment = browser.location.hash.replace(/^#\/?/, '');
|
|
13
|
+
return fragment.length ? fragment : undefined;
|
|
14
|
+
};
|
|
15
|
+
const href = (url)=>`${browser.location.pathname}${browser.location.search}#/${url ?? ''}`;
|
|
16
|
+
const stored = (value)=>value?.[stateKey];
|
|
17
|
+
return {
|
|
18
|
+
location,
|
|
19
|
+
state: ()=>stored(browser.history.state),
|
|
20
|
+
push: (state)=>browser.history.pushState({
|
|
21
|
+
[stateKey]: state
|
|
22
|
+
}, '', href(state.url)),
|
|
23
|
+
replace: (state)=>browser.history.replaceState({
|
|
24
|
+
[stateKey]: state
|
|
25
|
+
}, '', href(state.url)),
|
|
26
|
+
back: ()=>browser.history.back(),
|
|
27
|
+
listen: (listener)=>{
|
|
28
|
+
const onPopState = (event)=>listener(location(), stored(event.state));
|
|
29
|
+
const onHashChange = ()=>listener(location(), stored(browser.history.state));
|
|
30
|
+
browser.addEventListener('popstate', onPopState);
|
|
31
|
+
browser.addEventListener('hashchange', onHashChange);
|
|
32
|
+
return ()=>{
|
|
33
|
+
browser.removeEventListener('popstate', onPopState);
|
|
34
|
+
browser.removeEventListener('hashchange', onHashChange);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { createHashSceneHistory };
|
|
41
|
+
//# sourceMappingURL=createHashSceneHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHashSceneHistory.js","sources":["../../../navigation/createHashSceneHistory.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 { SceneBrowserWindow } from './createBrowserSceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationState } from './SceneNavigationState';\n\nconst stateKey = 'sceneNavigation';\n\n/**\n * A history kept in the URL fragment - `index.html#/WorkItemDetails?workItemId=B` - for hosts that are served\n * as a single file or from a path they do not control, such as a generated runtime or a webview. It behaves\n * like `createBrowserSceneHistory`: entries are pushed with their navigation state, back and forward restore\n * them, and a typed or bookmarked fragment is matched by URL alone. A fragment changed by hand, which fires\n * `hashchange` rather than `popstate`, is reported the same way.\n */\nexport function createHashSceneHistory(browser: SceneBrowserWindow = window): SceneHistory {\n const location = () => {\n const fragment = browser.location.hash.replace(/^#\\/?/, '');\n return fragment.length ? fragment : undefined;\n };\n const href = (url: string | undefined) => `${browser.location.pathname}${browser.location.search}#/${url ?? ''}`;\n const stored = (value: unknown) => (value as Record<string, SceneNavigationState> | null)?.[stateKey];\n\n return {\n location,\n state: () => stored(browser.history.state),\n push: state => browser.history.pushState({ [stateKey]: state }, '', href(state.url)),\n replace: state => browser.history.replaceState({ [stateKey]: state }, '', href(state.url)),\n back: () => browser.history.back(),\n listen: listener => {\n const onPopState = (event: PopStateEvent) => listener(location(), stored(event.state));\n const onHashChange = () => listener(location(), stored(browser.history.state));\n browser.addEventListener('popstate', onPopState);\n browser.addEventListener('hashchange', onHashChange);\n return () => {\n browser.removeEventListener('popstate', onPopState);\n browser.removeEventListener('hashchange', onHashChange);\n };\n },\n };\n}\n"],"names":["stateKey","createHashSceneHistory","browser","window","location","fragment","hash","replace","length","undefined","href","url","pathname","search","stored","value","state","history","push","pushState","replaceState","back","listen","listener","onPopState","event","onHashChange","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AAMA,MAAMA,QAAAA,GAAW,iBAAA;AAEjB;;;;;;AAMC,IACM,SAASC,sBAAAA,CAAuBC,OAAAA,GAA8BC,MAAM,EAAA;AACvE,IAAA,MAAMC,QAAAA,GAAW,IAAA;QACb,MAAMC,QAAAA,GAAWH,QAAQE,QAAQ,CAACE,IAAI,CAACC,OAAO,CAAC,OAAA,EAAS,EAAA,CAAA;QACxD,OAAOF,QAAAA,CAASG,MAAM,GAAGH,QAAAA,GAAWI,SAAAA;AACxC,IAAA,CAAA;AACA,IAAA,MAAMC,OAAO,CAACC,GAAAA,GAA4B,CAAA,EAAGT,OAAAA,CAAQE,QAAQ,CAACQ,QAAQ,CAAA,EAAGV,OAAAA,CAAQE,QAAQ,CAACS,MAAM,CAAC,EAAE,EAAEF,OAAO,EAAA,CAAA,CAAI;AAChH,IAAA,MAAMG,MAAAA,GAAS,CAACC,KAAAA,GAAoBA,KAAAA,GAAwDf,QAAAA,CAAS;IAErG,OAAO;AACHI,QAAAA,QAAAA;AACAY,QAAAA,KAAAA,EAAO,IAAMF,MAAAA,CAAOZ,OAAAA,CAAQe,OAAO,CAACD,KAAK,CAAA;AACzCE,QAAAA,IAAAA,EAAMF,CAAAA,KAAAA,GAASd,OAAAA,CAAQe,OAAO,CAACE,SAAS,CAAC;AAAE,gBAAA,CAACnB,WAAWgB;aAAM,EAAG,EAAA,EAAIN,IAAAA,CAAKM,KAAAA,CAAML,GAAG,CAAA,CAAA;AAClFJ,QAAAA,OAAAA,EAASS,CAAAA,KAAAA,GAASd,OAAAA,CAAQe,OAAO,CAACG,YAAY,CAAC;AAAE,gBAAA,CAACpB,WAAWgB;aAAM,EAAG,EAAA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