piral-menu
Advanced tools
Comparing version 0.8.0-pre.679 to 0.8.0-pre.682
@@ -6,9 +6,9 @@ "use strict"; | ||
function registerMenuItem(ctx, name, value) { | ||
react_atom_1.swap(ctx, state => (Object.assign({}, state, { components: Object.assign({}, state.components, { menuItems: piral_core_1.withKey(state.components.menuItems, name, value) }) }))); | ||
react_atom_1.swap(ctx, state => (Object.assign({}, state, { registry: Object.assign({}, state.registry, { menuItems: piral_core_1.withKey(state.registry.menuItems, name, value) }) }))); | ||
} | ||
exports.registerMenuItem = registerMenuItem; | ||
function unregisterMenuItem(ctx, name) { | ||
react_atom_1.swap(ctx, state => (Object.assign({}, state, { components: Object.assign({}, state.components, { menuItems: piral_core_1.withoutKey(state.components.menuItems, name) }) }))); | ||
react_atom_1.swap(ctx, state => (Object.assign({}, state, { registry: Object.assign({}, state.registry, { menuItems: piral_core_1.withoutKey(state.registry.menuItems, name) }) }))); | ||
} | ||
exports.unregisterMenuItem = unregisterMenuItem; | ||
//# sourceMappingURL=actions.js.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
const piral_core_1 = require("piral-core"); | ||
const default_1 = require("./default"); | ||
function getSettings(defaultSettings, customSettings = {}) { | ||
@@ -28,3 +29,3 @@ return Object.assign({ type: 'general' }, defaultSettings, customSettings); | ||
context.defineActions(actions); | ||
react_atom_1.swap(context.state, state => (Object.assign({}, state, { components: Object.assign({}, state.components, { menuItems: getMenuItems(items, defaultSettings) }) }))); | ||
react_atom_1.swap(context.state, state => (Object.assign({}, state, { components: Object.assign({}, state.components, { MenuContainer: default_1.DefaultContainer, MenuItem: default_1.DefaultItem }), registry: Object.assign({}, state.registry, { menuItems: getMenuItems(items, defaultSettings) }) }))); | ||
return (api, target) => { | ||
@@ -31,0 +32,0 @@ const prefix = target.name; |
export * from './create'; | ||
export * from './components'; | ||
export * from './Menu'; | ||
export * from './types'; |
@@ -5,2 +5,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./create"), exports); | ||
tslib_1.__exportStar(require("./components"), exports); | ||
tslib_1.__exportStar(require("./Menu"), exports); | ||
//# sourceMappingURL=index.js.map |
import { WrappedComponent, Dict, BaseComponentProps, AnyComponent } from 'piral-core'; | ||
import { ComponentType } from 'react'; | ||
declare module 'piral-core/lib/types/custom' { | ||
@@ -20,3 +21,3 @@ interface PiletCustomApi extends PiletMenuApi { | ||
} | ||
interface PiralCustomComponentsState { | ||
interface PiralCustomRegistryState { | ||
/** | ||
@@ -30,3 +31,31 @@ * The registered menu items for global display. | ||
} | ||
interface PiralCustomComponentsState { | ||
/** | ||
* The menu container component. | ||
*/ | ||
MenuContainer: ComponentType<MenuContainerProps>; | ||
/** | ||
* The menu item component. | ||
*/ | ||
MenuItem: ComponentType<MenuItemProps>; | ||
} | ||
} | ||
export interface MenuProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
export interface MenuContainerProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
export interface MenuItemProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
/** | ||
@@ -33,0 +62,0 @@ * The error used when a registered menu item component crashed. |
{ | ||
"name": "piral-menu", | ||
"version": "0.8.0-pre.679", | ||
"version": "0.8.0-pre.682", | ||
"description": "Extensions for the integration of menu items in Piral.", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "^0.8.0-pre.679" | ||
"piral-core": "^0.8.0-pre.682" | ||
}, | ||
@@ -43,3 +43,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "4cbfa79aedc070a50a81f76b345ad2394eb37299" | ||
"gitHead": "04da0183524adea0bae44c0f30f2b3ee1ce36e88" | ||
} |
@@ -8,3 +8,3 @@ import { Atom, deref } from '@dbeining/react-atom'; | ||
foo: 5, | ||
components: { | ||
registry: { | ||
foo: 5, | ||
@@ -17,3 +17,3 @@ menuItems: {}, | ||
foo: 5, | ||
components: { | ||
registry: { | ||
foo: 5, | ||
@@ -28,3 +28,3 @@ menuItems: { | ||
foo: 5, | ||
components: { | ||
registry: { | ||
foo: 5, | ||
@@ -31,0 +31,0 @@ menuItems: {}, |
@@ -8,5 +8,5 @@ import { Atom, swap } from '@dbeining/react-atom'; | ||
...state, | ||
components: { | ||
...state.components, | ||
menuItems: withKey(state.components.menuItems, name, value), | ||
registry: { | ||
...state.registry, | ||
menuItems: withKey(state.registry.menuItems, name, value), | ||
}, | ||
@@ -19,7 +19,7 @@ })); | ||
...state, | ||
components: { | ||
...state.components, | ||
menuItems: withoutKey(state.components.menuItems, name), | ||
registry: { | ||
...state.registry, | ||
menuItems: withoutKey(state.registry.menuItems, name), | ||
}, | ||
})); | ||
} |
@@ -5,2 +5,3 @@ import * as actions from './actions'; | ||
import { withApi, buildName, Extend, Dict } from 'piral-core'; | ||
import { DefaultContainer, DefaultItem } from './default'; | ||
import { PiletMenuApi, MenuSettings, MenuItemRegistration } from './types'; | ||
@@ -70,2 +71,7 @@ | ||
...state.components, | ||
MenuContainer: DefaultContainer, | ||
MenuItem: DefaultItem, | ||
}, | ||
registry: { | ||
...state.registry, | ||
menuItems: getMenuItems(items, defaultSettings), | ||
@@ -72,0 +78,0 @@ }, |
export * from './create'; | ||
export * from './components'; | ||
export * from './Menu'; | ||
export * from './types'; |
import { WrappedComponent, Dict, BaseComponentProps, AnyComponent } from 'piral-core'; | ||
import { ComponentType } from 'react'; | ||
@@ -22,3 +23,3 @@ declare module 'piral-core/lib/types/custom' { | ||
interface PiralCustomComponentsState { | ||
interface PiralCustomRegistryState { | ||
/** | ||
@@ -33,4 +34,36 @@ * The registered menu items for global display. | ||
} | ||
interface PiralCustomComponentsState { | ||
/** | ||
* The menu container component. | ||
*/ | ||
MenuContainer: ComponentType<MenuContainerProps>; | ||
/** | ||
* The menu item component. | ||
*/ | ||
MenuItem: ComponentType<MenuItemProps>; | ||
} | ||
} | ||
export interface MenuProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
export interface MenuContainerProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
export interface MenuItemProps { | ||
/** | ||
* The type of the menu. | ||
*/ | ||
type: MenuType; | ||
} | ||
/** | ||
@@ -37,0 +70,0 @@ * The error used when a registered menu item component crashed. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28079
33
598