Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function enhancedObservable(
data: any,
delegate: IEnhancedObservableDelegate
): any {
const o = Array.isArray(data) ? observable.array(data) : observable.box(data);
// Hook into the MobX observable and track
// Whether any Component is observing this observable.
const atom: any = getAtom(o);
const onBecomeUnobserved = atom.onBecomeUnobserved;
const reportObserved = atom.reportObserved;
let isObserved = false;
atom.isPendingUnobservation = false;
atom.onBecomeUnobserved = () => {
const res = onBecomeUnobserved.apply(atom, arguments);
if (isObserved) {
isObserved = false;
delegate.releaseObserverRef();
}
return res;
};
resourceStore: ResourceStore,
title?: string,
};
const FORM_STORE_UPDATE_ROUTE_HOOK_PRIORITY = 2048;
const HAS_CHANGED_ERROR_CODE = 1102;
@observer
class Form extends React.Component {
resourceStore: ResourceStore;
resourceFormStore: ResourceFormStore;
collaborationStore: ?CollaborationStore;
form: ?ElementRef;
@observable errors: Array = [];
showSuccess: IObservableValue = observable.box(false);
@observable toolbarActions: Array = [];
@observable showDirtyWarning: boolean = false;
@observable showHasChangedWarning: boolean = false;
postponedSaveOptions: Object;
postponedUpdateRouteMethod: ?UpdateRouteMethod;
postponedRoute: ?Route;
postponedRouteAttributes: ?AttributeMap;
checkFormStoreDirtyStateBeforeNavigationDisposer: () => void;
@computed get hasOwnResourceStore() {
const {resourceStore} = this.props;
return this.resourceKey && resourceStore.resourceKey !== this.resourceKey;
}
@computed.struct get locales() {
shape,
content,
size,
position,
transition,
duration,
easing,
disabled
}) {
this._label = label;
this._content = observable.box(getByLabel(CONTENTS, content));
this._size = observable.box(getByLabel(SIZES, size));
this._shape = observable.box(getByLabel(SHAPES, shape));
this._position = observable.box(getByLabel(POSITIONS, position));
this._transition = observable.box(getByLabel(TRANSITIONS, transition));
this._duration = observable.box(getByLabel(DURATIONS, duration));
this._easing = observable.box(getByLabel(EASINGS, easing));
this._disabled = observable.box(getByLabel(DISABLEDS, disabled));
}
import {
FirebaseDatabaseNode,
FirebaseDatabaseProvider,
FirebaseDatabaseNodes
} from "..";
import { FirebaseDatabaseMutation } from "../components/FirebaseDatabaseMutation";
import { FirebaseDatabaseTransaction } from "../components/FirebaseDatabaseTransaction";
import ReactJson from "react-json-view";
import { renderAndAddProps } from "render-and-add-props";
import { render } from "react-dom";
import { observable, IObservableValue } from "mobx";
import { observer } from "mobx-react";
export const formState = {
path: observable.box("posts"),
isList: observable.box(false),
keysOnly: observable.box(false),
limitToFirst: observable.box(2),
limitToLast: observable.box(undefined),
orderByChild: observable.box(undefined),
orderByKey: observable.box(undefined),
orderByValue: observable.box(undefined),
startAt: observable.box(undefined),
endAt: observable.box(undefined),
equalTo: observable.box(undefined),
once: observable.box(undefined)
};
const StringInput = observer(
({ obs, label = "" }: { obs: IObservableValue; label: string }) => {
return (
<div></div>
getCategoryTimestamp(category) {
if (!this.categoryTimestamps.has(category)) {
this.categoryTimestamps.set(category, observable.box(Date.now()));
}
return this.categoryTimestamps.get(category);
}
import { observable, computed, IObservableValue, IComputedValue } from 'mobx';
import { observer } from 'mobx-react'
import { CSSTransition } from 'react-transition-group'
import { TRANSITION_DURATION_SLOW } from 'constants/animation'
import { option } from 'engines/option'
import { process } from 'engines/process'
import { Background } from 'bases/materials/background'
import { menuStore } from 'bases/features/menu';
import { DockFixedAppList, DockRunningAppList } from './dock';
import { Tray } from './Tray';
import { Launcher } from './Launcher';
import styles from './header.module.scss';
export const sortingIndex: IObservableValue = observable.box(null)
export const tippingIndex: IObservableValue = observable.box(null)
export const calendarOperating: IObservableValue = observable.box(false)
export const isSomeDockItemOperating: IComputedValue = computed(
() => (sortingIndex.get() !== null) || (tippingIndex.get() !== null) || calendarOperating.get()
)
export const isDisabledTooltip: IComputedValue = computed(
() => isSomeDockItemOperating.get() || menuStore.visible
)
export const Header: React.FC = observer(() => {
return (
<div id="header">
event.preventDefault()}</div>
getNode() {
return (
);
}
errorMessage = observable.box('');
/**
* Controls the loading state of the dialog
*/
isLoading = observable.box(false);
/**
* Current page of results
*/
page = observable.box(0);
/**
* Controls the state of the input field
*/
query = observable.box('');
/**
* Array of results returned from the pubmed search
*/
results = observable([]);
@computed
get visibleResults(): CSL.Data[] {
const end = this.page.get() * 5;
const start = end - 6;
return this.results.filter((_result, i) => {
return start < i && i < end;
});
}
@action
id,
},
} = router;
const {
options: {
resourceKey,
},
} = route;
if (!resourceKey) {
throw new Error('The route does not define the mandatory "resourceKey" option');
}
const options = {};
if (this.locales) {
options.locale = observable.box();
router.bind('locale', options.locale);
}
if (id !== undefined && typeof id !== 'string' && typeof id !== 'number') {
throw new Error('The "id" router attribute must be a string or a number if given!');
}
this.resourceStore = new ResourceStore(resourceKey, id, options);
this.reloadResourceStoreOnRouteChangeDisposer = router.addUpdateRouteHook(
this.reloadResourceStoreOnRouteChange
);
}
selectRow(rows) {
let tr;
const b = observable.box();
autorun(() => b.set(rows()));
autorun(() => {
const s = this.selected;
if (tr) tr.className = '';
if (tr = s && b.get().find(tr => tr.model === s)) tr.className = 'danger';
});
return () => b.get();
}