@bpmn-io/properties-panel 0.7.0 → 0.10.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/CHANGELOG.md +25 -0
- package/assets/properties-panel.css +42 -1
- package/dist/index.esm.js +1607 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1648 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -7
- package/preact/LICENSE +21 -0
- package/preact/README.md +185 -0
- package/preact/compat/dist/compat.js +2 -0
- package/preact/compat/dist/compat.js.map +1 -0
- package/preact/compat/dist/compat.mjs +2 -0
- package/preact/compat/dist/compat.module.js +2 -0
- package/preact/compat/dist/compat.module.js.map +1 -0
- package/preact/compat/dist/compat.umd.js +2 -0
- package/preact/compat/dist/compat.umd.js.map +1 -0
- package/preact/compat/jsx-dev-runtime.js +1 -0
- package/preact/compat/jsx-dev-runtime.mjs +1 -0
- package/preact/compat/jsx-runtime.js +1 -0
- package/preact/compat/jsx-runtime.mjs +1 -0
- package/preact/compat/package.json +19 -0
- package/preact/compat/server.js +15 -0
- package/preact/compat/server.mjs +4 -0
- package/preact/compat/src/Children.js +21 -0
- package/preact/compat/src/PureComponent.js +15 -0
- package/preact/compat/src/forwardRef.js +51 -0
- package/preact/compat/src/index.d.ts +140 -0
- package/preact/compat/src/index.js +175 -0
- package/preact/compat/src/internal.d.ts +47 -0
- package/preact/compat/src/memo.js +34 -0
- package/preact/compat/src/portals.js +80 -0
- package/preact/compat/src/render.js +219 -0
- package/preact/compat/src/scheduler.js +24 -0
- package/preact/compat/src/suspense-list.d.ts +14 -0
- package/preact/compat/src/suspense-list.js +126 -0
- package/preact/compat/src/suspense.d.ts +15 -0
- package/preact/compat/src/suspense.js +270 -0
- package/preact/compat/src/util.js +28 -0
- package/preact/compat/test-utils.js +1 -0
- package/preact/debug/dist/debug.js +2 -0
- package/preact/debug/dist/debug.js.map +1 -0
- package/preact/debug/dist/debug.mjs +2 -0
- package/preact/debug/dist/debug.module.js +2 -0
- package/preact/debug/dist/debug.module.js.map +1 -0
- package/preact/debug/dist/debug.umd.js +2 -0
- package/preact/debug/dist/debug.umd.js.map +1 -0
- package/preact/debug/package.json +18 -0
- package/preact/debug/src/check-props.js +54 -0
- package/preact/debug/src/component-stack.js +146 -0
- package/preact/debug/src/constants.js +3 -0
- package/preact/debug/src/debug.js +442 -0
- package/preact/debug/src/index.js +6 -0
- package/preact/debug/src/internal.d.ts +82 -0
- package/preact/debug/src/util.js +11 -0
- package/preact/devtools/dist/devtools.js +2 -0
- package/preact/devtools/dist/devtools.js.map +1 -0
- package/preact/devtools/dist/devtools.mjs +2 -0
- package/preact/devtools/dist/devtools.module.js +2 -0
- package/preact/devtools/dist/devtools.module.js.map +1 -0
- package/preact/devtools/dist/devtools.umd.js +2 -0
- package/preact/devtools/dist/devtools.umd.js.map +1 -0
- package/preact/devtools/package.json +16 -0
- package/preact/devtools/src/devtools.js +10 -0
- package/preact/devtools/src/index.d.ts +8 -0
- package/preact/devtools/src/index.js +15 -0
- package/preact/dist/preact.js +2 -0
- package/preact/dist/preact.js.map +1 -0
- package/preact/dist/preact.min.js +2 -0
- package/preact/dist/preact.min.js.map +1 -0
- package/preact/dist/preact.mjs +2 -0
- package/preact/dist/preact.module.js +2 -0
- package/preact/dist/preact.module.js.map +1 -0
- package/preact/dist/preact.umd.js +2 -0
- package/preact/dist/preact.umd.js.map +1 -0
- package/preact/hooks/dist/hooks.js +2 -0
- package/preact/hooks/dist/hooks.js.map +1 -0
- package/preact/hooks/dist/hooks.mjs +2 -0
- package/preact/hooks/dist/hooks.module.js +2 -0
- package/preact/hooks/dist/hooks.module.js.map +1 -0
- package/preact/hooks/dist/hooks.umd.js +2 -0
- package/preact/hooks/dist/hooks.umd.js.map +1 -0
- package/preact/hooks/package.json +26 -0
- package/preact/hooks/src/index.d.ts +130 -0
- package/preact/hooks/src/index.js +386 -0
- package/preact/hooks/src/internal.d.ts +75 -0
- package/preact/jsx-runtime/dist/jsxRuntime.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -0
- package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.module.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -0
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -0
- package/preact/jsx-runtime/package.json +19 -0
- package/preact/jsx-runtime/src/index.d.ts +50 -0
- package/preact/jsx-runtime/src/index.js +72 -0
- package/preact/package.json +268 -0
- package/preact/src/cjs.js +3 -0
- package/preact/src/clone-element.js +39 -0
- package/preact/src/component.js +225 -0
- package/preact/src/constants.js +3 -0
- package/preact/src/create-context.js +68 -0
- package/preact/src/create-element.js +100 -0
- package/preact/src/diff/catch-error.js +38 -0
- package/preact/src/diff/children.js +347 -0
- package/preact/src/diff/index.js +516 -0
- package/preact/src/diff/props.js +158 -0
- package/preact/src/index.d.ts +310 -0
- package/preact/src/index.js +13 -0
- package/preact/src/internal.d.ts +147 -0
- package/preact/src/jsx.d.ts +955 -0
- package/preact/src/options.js +17 -0
- package/preact/src/render.js +74 -0
- package/preact/src/util.js +23 -0
- package/preact/test-utils/dist/testUtils.js +2 -0
- package/preact/test-utils/dist/testUtils.js.map +1 -0
- package/preact/test-utils/dist/testUtils.mjs +2 -0
- package/preact/test-utils/dist/testUtils.module.js +2 -0
- package/preact/test-utils/dist/testUtils.module.js.map +1 -0
- package/preact/test-utils/dist/testUtils.umd.js +2 -0
- package/preact/test-utils/dist/testUtils.umd.js.map +1 -0
- package/preact/test-utils/package.json +19 -0
- package/preact/test-utils/src/index.d.ts +3 -0
- package/preact/test-utils/src/index.js +117 -0
- package/lib/PropertiesPanel.js +0 -126
- package/lib/PropertiesPanel.js.map +0 -1
- package/lib/components/DropdownButton.js +0 -109
- package/lib/components/DropdownButton.js.map +0 -1
- package/lib/components/Group.js +0 -75
- package/lib/components/Group.js.map +0 -1
- package/lib/components/Header.js +0 -49
- package/lib/components/Header.js.map +0 -1
- package/lib/components/HeaderButton.js +0 -16
- package/lib/components/HeaderButton.js.map +0 -1
- package/lib/components/ListGroup.js +0 -167
- package/lib/components/ListGroup.js.map +0 -1
- package/lib/components/ListItem.js +0 -37
- package/lib/components/ListItem.js.map +0 -1
- package/lib/components/entries/Checkbox.js +0 -76
- package/lib/components/entries/Checkbox.js.map +0 -1
- package/lib/components/entries/Collapsible.js +0 -48
- package/lib/components/entries/Collapsible.js.map +0 -1
- package/lib/components/entries/List.js +0 -204
- package/lib/components/entries/List.js.map +0 -1
- package/lib/components/entries/NumberField.js +0 -108
- package/lib/components/entries/NumberField.js.map +0 -1
- package/lib/components/entries/Select.js +0 -101
- package/lib/components/entries/Select.js.map +0 -1
- package/lib/components/entries/Simple.js +0 -56
- package/lib/components/entries/Simple.js.map +0 -1
- package/lib/components/entries/TextArea.js +0 -91
- package/lib/components/entries/TextArea.js.map +0 -1
- package/lib/components/entries/TextField.js +0 -121
- package/lib/components/entries/TextField.js.map +0 -1
- package/lib/components/entries/ToggleSwitch.js +0 -87
- package/lib/components/entries/ToggleSwitch.js.map +0 -1
- package/lib/components/icons/index.js +0 -51
- package/lib/components/icons/index.js.map +0 -1
- package/lib/context/LayoutContext.js +0 -9
- package/lib/context/LayoutContext.js.map +0 -1
- package/lib/context/index.js +0 -2
- package/lib/context/index.js.map +0 -1
- package/lib/features/debounce-input/debounceInput.js +0 -14
- package/lib/features/debounce-input/debounceInput.js.map +0 -1
- package/lib/features/debounce-input/index.js +0 -5
- package/lib/features/debounce-input/index.js.map +0 -1
- package/lib/hooks/index.js +0 -4
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useKeyFactory.js +0 -39
- package/lib/hooks/useKeyFactory.js.map +0 -1
- package/lib/hooks/useLayoutState.js +0 -36
- package/lib/hooks/useLayoutState.js.map +0 -1
- package/lib/hooks/usePrevious.js +0 -16
- package/lib/hooks/usePrevious.js.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as _hooks from '../../hooks';
|
|
2
|
+
import * as preact from '../../src';
|
|
3
|
+
import { JSXInternal } from '../../src/jsx';
|
|
4
|
+
import * as _Suspense from './suspense';
|
|
5
|
+
import * as _SuspenseList from './suspense-list';
|
|
6
|
+
|
|
7
|
+
// export default React;
|
|
8
|
+
export = React;
|
|
9
|
+
export as namespace React;
|
|
10
|
+
declare namespace React {
|
|
11
|
+
// Export JSX
|
|
12
|
+
export import JSX = JSXInternal;
|
|
13
|
+
|
|
14
|
+
// Hooks
|
|
15
|
+
export import CreateHandle = _hooks.CreateHandle;
|
|
16
|
+
export import EffectCallback = _hooks.EffectCallback;
|
|
17
|
+
export import Inputs = _hooks.Inputs;
|
|
18
|
+
export import PropRef = _hooks.PropRef;
|
|
19
|
+
export import Reducer = _hooks.Reducer;
|
|
20
|
+
export import Ref = _hooks.Ref;
|
|
21
|
+
export import StateUpdater = _hooks.StateUpdater;
|
|
22
|
+
export import useCallback = _hooks.useCallback;
|
|
23
|
+
export import useContext = _hooks.useContext;
|
|
24
|
+
export import useDebugValue = _hooks.useDebugValue;
|
|
25
|
+
export import useEffect = _hooks.useEffect;
|
|
26
|
+
export import useImperativeHandle = _hooks.useImperativeHandle;
|
|
27
|
+
export import useLayoutEffect = _hooks.useLayoutEffect;
|
|
28
|
+
export import useMemo = _hooks.useMemo;
|
|
29
|
+
export import useReducer = _hooks.useReducer;
|
|
30
|
+
export import useRef = _hooks.useRef;
|
|
31
|
+
export import useState = _hooks.useState;
|
|
32
|
+
|
|
33
|
+
// Preact Defaults
|
|
34
|
+
export import Component = preact.Component;
|
|
35
|
+
export import FunctionComponent = preact.FunctionComponent;
|
|
36
|
+
export import FC = preact.FunctionComponent;
|
|
37
|
+
export import createContext = preact.createContext;
|
|
38
|
+
export import createRef = preact.createRef;
|
|
39
|
+
export import Fragment = preact.Fragment;
|
|
40
|
+
export import createElement = preact.createElement;
|
|
41
|
+
export import cloneElement = preact.cloneElement;
|
|
42
|
+
|
|
43
|
+
// Suspense
|
|
44
|
+
export import Suspense = _Suspense.Suspense;
|
|
45
|
+
export import lazy = _Suspense.lazy;
|
|
46
|
+
export import SuspenseList = _SuspenseList.SuspenseList;
|
|
47
|
+
|
|
48
|
+
// Compat
|
|
49
|
+
export import StrictMode = preact.Fragment;
|
|
50
|
+
export const version: string;
|
|
51
|
+
|
|
52
|
+
export function createPortal(
|
|
53
|
+
vnode: preact.VNode,
|
|
54
|
+
container: Element
|
|
55
|
+
): preact.VNode<any>;
|
|
56
|
+
|
|
57
|
+
export function render(
|
|
58
|
+
vnode: preact.VNode<any>,
|
|
59
|
+
parent: Element,
|
|
60
|
+
callback?: () => void
|
|
61
|
+
): Component | null;
|
|
62
|
+
|
|
63
|
+
export function hydrate(
|
|
64
|
+
vnode: preact.VNode<any>,
|
|
65
|
+
parent: Element,
|
|
66
|
+
callback?: () => void
|
|
67
|
+
): Component | null;
|
|
68
|
+
|
|
69
|
+
export function unmountComponentAtNode(
|
|
70
|
+
container: Element | Document | ShadowRoot | DocumentFragment
|
|
71
|
+
): boolean;
|
|
72
|
+
|
|
73
|
+
export function createFactory(
|
|
74
|
+
type: preact.VNode<any>['type']
|
|
75
|
+
): (
|
|
76
|
+
props?: any,
|
|
77
|
+
...children: preact.ComponentChildren[]
|
|
78
|
+
) => preact.VNode<any>;
|
|
79
|
+
export function isValidElement(element: any): boolean;
|
|
80
|
+
export function findDOMNode(component: preact.Component): Element | null;
|
|
81
|
+
|
|
82
|
+
export abstract class PureComponent<P = {}, S = {}> extends preact.Component<
|
|
83
|
+
P,
|
|
84
|
+
S
|
|
85
|
+
> {
|
|
86
|
+
isPureReactComponent: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function memo<P = {}>(
|
|
90
|
+
component: preact.FunctionalComponent<P>,
|
|
91
|
+
comparer?: (prev: P, next: P) => boolean
|
|
92
|
+
): preact.FunctionComponent<P>;
|
|
93
|
+
export function memo<C extends preact.FunctionalComponent<any>>(
|
|
94
|
+
component: C,
|
|
95
|
+
comparer?: (
|
|
96
|
+
prev: preact.ComponentProps<C>,
|
|
97
|
+
next: preact.ComponentProps<C>
|
|
98
|
+
) => boolean
|
|
99
|
+
): C;
|
|
100
|
+
|
|
101
|
+
export interface ForwardFn<P = {}, T = any> {
|
|
102
|
+
(props: P, ref: Ref<T>): preact.ComponentChild;
|
|
103
|
+
displayName?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function forwardRef<R, P = {}>(
|
|
107
|
+
fn: ForwardFn<P, R>
|
|
108
|
+
): preact.FunctionalComponent<P>;
|
|
109
|
+
|
|
110
|
+
export function unstable_batchedUpdates(
|
|
111
|
+
callback: (arg?: any) => void,
|
|
112
|
+
arg?: any
|
|
113
|
+
): void;
|
|
114
|
+
|
|
115
|
+
export const Children: {
|
|
116
|
+
map<T extends preact.ComponentChild, R>(
|
|
117
|
+
children: T | T[],
|
|
118
|
+
fn: (child: T, i: number) => R
|
|
119
|
+
): R[];
|
|
120
|
+
forEach<T extends preact.ComponentChild>(
|
|
121
|
+
children: T | T[],
|
|
122
|
+
fn: (child: T, i: number) => void
|
|
123
|
+
): void;
|
|
124
|
+
count: (children: preact.ComponentChildren) => number;
|
|
125
|
+
only: (children: preact.ComponentChildren) => preact.ComponentChild;
|
|
126
|
+
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// scheduler
|
|
130
|
+
export const unstable_ImmediatePriority: number;
|
|
131
|
+
export const unstable_UserBlockingPriority: number;
|
|
132
|
+
export const unstable_NormalPriority: number;
|
|
133
|
+
export const unstable_LowPriority: number;
|
|
134
|
+
export const unstable_IdlePriority: number;
|
|
135
|
+
export function unstable_runWithPriority(
|
|
136
|
+
priority: number,
|
|
137
|
+
callback: () => void
|
|
138
|
+
): void;
|
|
139
|
+
export const unstable_now: () => number;
|
|
140
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createElement,
|
|
3
|
+
render as preactRender,
|
|
4
|
+
cloneElement as preactCloneElement,
|
|
5
|
+
createRef,
|
|
6
|
+
Component,
|
|
7
|
+
createContext,
|
|
8
|
+
Fragment
|
|
9
|
+
} from '../..';
|
|
10
|
+
import {
|
|
11
|
+
useState,
|
|
12
|
+
useReducer,
|
|
13
|
+
useEffect,
|
|
14
|
+
useLayoutEffect,
|
|
15
|
+
useRef,
|
|
16
|
+
useImperativeHandle,
|
|
17
|
+
useMemo,
|
|
18
|
+
useCallback,
|
|
19
|
+
useContext,
|
|
20
|
+
useDebugValue
|
|
21
|
+
} from '../../hooks';
|
|
22
|
+
import { PureComponent } from './PureComponent';
|
|
23
|
+
import { memo } from './memo';
|
|
24
|
+
import { forwardRef } from './forwardRef';
|
|
25
|
+
import { Children } from './Children';
|
|
26
|
+
import { Suspense, lazy } from './suspense';
|
|
27
|
+
import { SuspenseList } from './suspense-list';
|
|
28
|
+
import { createPortal } from './portals';
|
|
29
|
+
import {
|
|
30
|
+
hydrate,
|
|
31
|
+
render,
|
|
32
|
+
REACT_ELEMENT_TYPE,
|
|
33
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
34
|
+
} from './render';
|
|
35
|
+
export * from './scheduler';
|
|
36
|
+
|
|
37
|
+
const version = '16.8.0'; // trick libraries to think we are react
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Legacy version of createElement.
|
|
41
|
+
* @param {import('./internal').VNode["type"]} type The node name or Component constructor
|
|
42
|
+
*/
|
|
43
|
+
function createFactory(type) {
|
|
44
|
+
return createElement.bind(null, type);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check if the passed element is a valid (p)react node.
|
|
49
|
+
* @param {*} element The element to check
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
function isValidElement(element) {
|
|
53
|
+
return !!element && element.$$typeof === REACT_ELEMENT_TYPE;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Wrap `cloneElement` to abort if the passed element is not a valid element and apply
|
|
58
|
+
* all vnode normalizations.
|
|
59
|
+
* @param {import('./internal').VNode} element The vnode to clone
|
|
60
|
+
* @param {object} props Props to add when cloning
|
|
61
|
+
* @param {Array<import('./internal').ComponentChildren>} rest Optional component children
|
|
62
|
+
*/
|
|
63
|
+
function cloneElement(element) {
|
|
64
|
+
if (!isValidElement(element)) return element;
|
|
65
|
+
return preactCloneElement.apply(null, arguments);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Remove a component tree from the DOM, including state and event handlers.
|
|
70
|
+
* @param {import('./internal').PreactElement} container
|
|
71
|
+
* @returns {boolean}
|
|
72
|
+
*/
|
|
73
|
+
function unmountComponentAtNode(container) {
|
|
74
|
+
if (container._children) {
|
|
75
|
+
preactRender(null, container);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the matching DOM node for a component
|
|
83
|
+
* @param {import('./internal').Component} component
|
|
84
|
+
* @returns {import('./internal').PreactElement | null}
|
|
85
|
+
*/
|
|
86
|
+
function findDOMNode(component) {
|
|
87
|
+
return (
|
|
88
|
+
(component &&
|
|
89
|
+
(component.base || (component.nodeType === 1 && component))) ||
|
|
90
|
+
null
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Deprecated way to control batched rendering inside the reconciler, but we
|
|
96
|
+
* already schedule in batches inside our rendering code
|
|
97
|
+
* @template Arg
|
|
98
|
+
* @param {(arg: Arg) => void} callback function that triggers the updated
|
|
99
|
+
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
|
100
|
+
*/
|
|
101
|
+
// eslint-disable-next-line camelcase
|
|
102
|
+
const unstable_batchedUpdates = (callback, arg) => callback(arg);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Strict Mode is not implemented in Preact, so we provide a stand-in for it
|
|
106
|
+
* that just renders its children without imposing any restrictions.
|
|
107
|
+
*/
|
|
108
|
+
const StrictMode = Fragment;
|
|
109
|
+
|
|
110
|
+
export * from '../../hooks';
|
|
111
|
+
export {
|
|
112
|
+
version,
|
|
113
|
+
Children,
|
|
114
|
+
render,
|
|
115
|
+
hydrate,
|
|
116
|
+
unmountComponentAtNode,
|
|
117
|
+
createPortal,
|
|
118
|
+
createElement,
|
|
119
|
+
createContext,
|
|
120
|
+
createFactory,
|
|
121
|
+
cloneElement,
|
|
122
|
+
createRef,
|
|
123
|
+
Fragment,
|
|
124
|
+
isValidElement,
|
|
125
|
+
findDOMNode,
|
|
126
|
+
Component,
|
|
127
|
+
PureComponent,
|
|
128
|
+
memo,
|
|
129
|
+
forwardRef,
|
|
130
|
+
// eslint-disable-next-line camelcase
|
|
131
|
+
unstable_batchedUpdates,
|
|
132
|
+
StrictMode,
|
|
133
|
+
Suspense,
|
|
134
|
+
SuspenseList,
|
|
135
|
+
lazy,
|
|
136
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// React copies the named exports to the default one.
|
|
140
|
+
export default {
|
|
141
|
+
useState,
|
|
142
|
+
useReducer,
|
|
143
|
+
useEffect,
|
|
144
|
+
useLayoutEffect,
|
|
145
|
+
useRef,
|
|
146
|
+
useImperativeHandle,
|
|
147
|
+
useMemo,
|
|
148
|
+
useCallback,
|
|
149
|
+
useContext,
|
|
150
|
+
useDebugValue,
|
|
151
|
+
version,
|
|
152
|
+
Children,
|
|
153
|
+
render,
|
|
154
|
+
hydrate,
|
|
155
|
+
unmountComponentAtNode,
|
|
156
|
+
createPortal,
|
|
157
|
+
createElement,
|
|
158
|
+
createContext,
|
|
159
|
+
createFactory,
|
|
160
|
+
cloneElement,
|
|
161
|
+
createRef,
|
|
162
|
+
Fragment,
|
|
163
|
+
isValidElement,
|
|
164
|
+
findDOMNode,
|
|
165
|
+
Component,
|
|
166
|
+
PureComponent,
|
|
167
|
+
memo,
|
|
168
|
+
forwardRef,
|
|
169
|
+
unstable_batchedUpdates,
|
|
170
|
+
StrictMode,
|
|
171
|
+
Suspense,
|
|
172
|
+
SuspenseList,
|
|
173
|
+
lazy,
|
|
174
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
175
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component as PreactComponent,
|
|
3
|
+
VNode as PreactVNode,
|
|
4
|
+
FunctionComponent as PreactFunctionComponent
|
|
5
|
+
} from '../../src/internal';
|
|
6
|
+
import { SuspenseProps } from './suspense';
|
|
7
|
+
|
|
8
|
+
export { ComponentChildren } from '../..';
|
|
9
|
+
|
|
10
|
+
export { PreactElement } from '../../src/internal';
|
|
11
|
+
|
|
12
|
+
export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
|
|
13
|
+
isReactComponent?: object;
|
|
14
|
+
isPureReactComponent?: true;
|
|
15
|
+
_patchedLifecycles?: true;
|
|
16
|
+
|
|
17
|
+
// Suspense internal properties
|
|
18
|
+
_childDidSuspend?(error: Promise<void>, suspendingVNode: VNode): void;
|
|
19
|
+
_suspended: (vnode: VNode) => (unsuspend: () => void) => void;
|
|
20
|
+
_onResolve?(): void;
|
|
21
|
+
|
|
22
|
+
// Portal internal properties
|
|
23
|
+
_temp: any;
|
|
24
|
+
_container: PreactElement;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FunctionComponent<P = {}> extends PreactFunctionComponent<P> {
|
|
28
|
+
shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
|
|
29
|
+
_forwarded?: boolean;
|
|
30
|
+
_patchedLifecycles?: true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface VNode<T = any> extends PreactVNode<T> {
|
|
34
|
+
$$typeof?: symbol | string;
|
|
35
|
+
preactCompatNormalized?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SuspenseState {
|
|
39
|
+
_suspended?: null | VNode<any>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface SuspenseComponent
|
|
43
|
+
extends PreactComponent<SuspenseProps, SuspenseState> {
|
|
44
|
+
_pendingSuspensionCount: number;
|
|
45
|
+
_suspenders: Component[];
|
|
46
|
+
_detachOnNextRender: null | VNode<any>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createElement } from '../..';
|
|
2
|
+
import { shallowDiffers } from './util';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Memoize a component, so that it only updates when the props actually have
|
|
6
|
+
* changed. This was previously known as `React.pure`.
|
|
7
|
+
* @param {import('./internal').FunctionComponent} c functional component
|
|
8
|
+
* @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
|
|
9
|
+
* @returns {import('./internal').FunctionComponent}
|
|
10
|
+
*/
|
|
11
|
+
export function memo(c, comparer) {
|
|
12
|
+
function shouldUpdate(nextProps) {
|
|
13
|
+
let ref = this.props.ref;
|
|
14
|
+
let updateRef = ref == nextProps.ref;
|
|
15
|
+
if (!updateRef && ref) {
|
|
16
|
+
ref.call ? ref(null) : (ref.current = null);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!comparer) {
|
|
20
|
+
return shallowDiffers(this.props, nextProps);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return !comparer(this.props, nextProps) || !updateRef;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function Memoed(props) {
|
|
27
|
+
this.shouldComponentUpdate = shouldUpdate;
|
|
28
|
+
return createElement(c, props);
|
|
29
|
+
}
|
|
30
|
+
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
|
|
31
|
+
Memoed.prototype.isReactComponent = true;
|
|
32
|
+
Memoed._forwarded = true;
|
|
33
|
+
return Memoed;
|
|
34
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createElement, render } from '../..';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
|
5
|
+
*/
|
|
6
|
+
function ContextProvider(props) {
|
|
7
|
+
this.getChildContext = () => props.context;
|
|
8
|
+
return props.children;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Portal component
|
|
13
|
+
* @this {import('./internal').Component}
|
|
14
|
+
* @param {object | null | undefined} props
|
|
15
|
+
*
|
|
16
|
+
* TODO: use createRoot() instead of fake root
|
|
17
|
+
*/
|
|
18
|
+
function Portal(props) {
|
|
19
|
+
const _this = this;
|
|
20
|
+
let container = props._container;
|
|
21
|
+
|
|
22
|
+
_this.componentWillUnmount = function() {
|
|
23
|
+
render(null, _this._temp);
|
|
24
|
+
_this._temp = null;
|
|
25
|
+
_this._container = null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// When we change container we should clear our old container and
|
|
29
|
+
// indicate a new mount.
|
|
30
|
+
if (_this._container && _this._container !== container) {
|
|
31
|
+
_this.componentWillUnmount();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// When props.vnode is undefined/false/null we are dealing with some kind of
|
|
35
|
+
// conditional vnode. This should not trigger a render.
|
|
36
|
+
if (props._vnode) {
|
|
37
|
+
if (!_this._temp) {
|
|
38
|
+
_this._container = container;
|
|
39
|
+
|
|
40
|
+
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
|
41
|
+
_this._temp = {
|
|
42
|
+
nodeType: 1,
|
|
43
|
+
parentNode: container,
|
|
44
|
+
childNodes: [],
|
|
45
|
+
appendChild(child) {
|
|
46
|
+
this.childNodes.push(child);
|
|
47
|
+
_this._container.appendChild(child);
|
|
48
|
+
},
|
|
49
|
+
insertBefore(child, before) {
|
|
50
|
+
this.childNodes.push(child);
|
|
51
|
+
_this._container.appendChild(child);
|
|
52
|
+
},
|
|
53
|
+
removeChild(child) {
|
|
54
|
+
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
|
55
|
+
_this._container.removeChild(child);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Render our wrapping element into temp.
|
|
61
|
+
render(
|
|
62
|
+
createElement(ContextProvider, { context: _this.context }, props._vnode),
|
|
63
|
+
_this._temp
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
// When we come from a conditional render, on a mounted
|
|
67
|
+
// portal we should clear the DOM.
|
|
68
|
+
else if (_this._temp) {
|
|
69
|
+
_this.componentWillUnmount();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
|
75
|
+
* @param {import('./internal').VNode} vnode The vnode to render
|
|
76
|
+
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
|
77
|
+
*/
|
|
78
|
+
export function createPortal(vnode, container) {
|
|
79
|
+
return createElement(Portal, { _vnode: vnode, _container: container });
|
|
80
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
render as preactRender,
|
|
3
|
+
hydrate as preactHydrate,
|
|
4
|
+
options,
|
|
5
|
+
toChildArray,
|
|
6
|
+
Component
|
|
7
|
+
} from '../..';
|
|
8
|
+
|
|
9
|
+
export const REACT_ELEMENT_TYPE =
|
|
10
|
+
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
|
11
|
+
0xeac7;
|
|
12
|
+
|
|
13
|
+
const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
|
14
|
+
|
|
15
|
+
// Input types for which onchange should not be converted to oninput.
|
|
16
|
+
// type="file|checkbox|radio", plus "range" in IE11.
|
|
17
|
+
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
|
18
|
+
const onChangeInputType = type =>
|
|
19
|
+
(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
|
|
20
|
+
? /fil|che|rad/i
|
|
21
|
+
: /fil|che|ra/i
|
|
22
|
+
).test(type);
|
|
23
|
+
|
|
24
|
+
// Some libraries like `react-virtualized` explicitly check for this.
|
|
25
|
+
Component.prototype.isReactComponent = {};
|
|
26
|
+
|
|
27
|
+
// `UNSAFE_*` lifecycle hooks
|
|
28
|
+
// Preact only ever invokes the unprefixed methods.
|
|
29
|
+
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
|
30
|
+
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
|
31
|
+
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
|
32
|
+
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
|
33
|
+
// See https://github.com/preactjs/preact/issues/1941
|
|
34
|
+
[
|
|
35
|
+
'componentWillMount',
|
|
36
|
+
'componentWillReceiveProps',
|
|
37
|
+
'componentWillUpdate'
|
|
38
|
+
].forEach(key => {
|
|
39
|
+
Object.defineProperty(Component.prototype, key, {
|
|
40
|
+
configurable: true,
|
|
41
|
+
get() {
|
|
42
|
+
return this['UNSAFE_' + key];
|
|
43
|
+
},
|
|
44
|
+
set(v) {
|
|
45
|
+
Object.defineProperty(this, key, {
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: v
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Proxy render() since React returns a Component reference.
|
|
56
|
+
* @param {import('./internal').VNode} vnode VNode tree to render
|
|
57
|
+
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
|
58
|
+
* @param {() => void} [callback] Optional callback that will be called after rendering
|
|
59
|
+
* @returns {import('./internal').Component | null} The root component reference or null
|
|
60
|
+
*/
|
|
61
|
+
export function render(vnode, parent, callback) {
|
|
62
|
+
// React destroys any existing DOM nodes, see #1727
|
|
63
|
+
// ...but only on the first render, see #1828
|
|
64
|
+
if (parent._children == null) {
|
|
65
|
+
parent.textContent = '';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
preactRender(vnode, parent);
|
|
69
|
+
if (typeof callback == 'function') callback();
|
|
70
|
+
|
|
71
|
+
return vnode ? vnode._component : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function hydrate(vnode, parent, callback) {
|
|
75
|
+
preactHydrate(vnode, parent);
|
|
76
|
+
if (typeof callback == 'function') callback();
|
|
77
|
+
|
|
78
|
+
return vnode ? vnode._component : null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let oldEventHook = options.event;
|
|
82
|
+
options.event = e => {
|
|
83
|
+
if (oldEventHook) e = oldEventHook(e);
|
|
84
|
+
e.persist = empty;
|
|
85
|
+
e.isPropagationStopped = isPropagationStopped;
|
|
86
|
+
e.isDefaultPrevented = isDefaultPrevented;
|
|
87
|
+
return (e.nativeEvent = e);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
function empty() {}
|
|
91
|
+
|
|
92
|
+
function isPropagationStopped() {
|
|
93
|
+
return this.cancelBubble;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isDefaultPrevented() {
|
|
97
|
+
return this.defaultPrevented;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let classNameDescriptor = {
|
|
101
|
+
configurable: true,
|
|
102
|
+
get() {
|
|
103
|
+
return this.class;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
let oldVNodeHook = options.vnode;
|
|
108
|
+
options.vnode = vnode => {
|
|
109
|
+
let type = vnode.type;
|
|
110
|
+
let props = vnode.props;
|
|
111
|
+
let normalizedProps = props;
|
|
112
|
+
|
|
113
|
+
// only normalize props on Element nodes
|
|
114
|
+
if (typeof type === 'string') {
|
|
115
|
+
normalizedProps = {};
|
|
116
|
+
|
|
117
|
+
for (let i in props) {
|
|
118
|
+
let value = props[i];
|
|
119
|
+
|
|
120
|
+
if (i === 'value' && 'defaultValue' in props && value == null) {
|
|
121
|
+
// Skip applying value if it is null/undefined and we already set
|
|
122
|
+
// a default value
|
|
123
|
+
continue;
|
|
124
|
+
} else if (
|
|
125
|
+
i === 'defaultValue' &&
|
|
126
|
+
'value' in props &&
|
|
127
|
+
props.value == null
|
|
128
|
+
) {
|
|
129
|
+
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
|
130
|
+
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
|
131
|
+
i = 'value';
|
|
132
|
+
} else if (i === 'download' && value === true) {
|
|
133
|
+
// Calling `setAttribute` with a truthy value will lead to it being
|
|
134
|
+
// passed as a stringified value, e.g. `download="true"`. React
|
|
135
|
+
// converts it to an empty string instead, otherwise the attribute
|
|
136
|
+
// value will be used as the file name and the file will be called
|
|
137
|
+
// "true" upon downloading it.
|
|
138
|
+
value = '';
|
|
139
|
+
} else if (/ondoubleclick/i.test(i)) {
|
|
140
|
+
i = 'ondblclick';
|
|
141
|
+
} else if (
|
|
142
|
+
/^onchange(textarea|input)/i.test(i + type) &&
|
|
143
|
+
!onChangeInputType(props.type)
|
|
144
|
+
) {
|
|
145
|
+
i = 'oninput';
|
|
146
|
+
} else if (/^on(Ani|Tra|Tou|BeforeInp)/.test(i)) {
|
|
147
|
+
i = i.toLowerCase();
|
|
148
|
+
} else if (CAMEL_PROPS.test(i)) {
|
|
149
|
+
i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
|
|
150
|
+
} else if (value === null) {
|
|
151
|
+
value = undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
normalizedProps[i] = value;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Add support for array select values: <select multiple value={[]} />
|
|
158
|
+
if (
|
|
159
|
+
type == 'select' &&
|
|
160
|
+
normalizedProps.multiple &&
|
|
161
|
+
Array.isArray(normalizedProps.value)
|
|
162
|
+
) {
|
|
163
|
+
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
|
164
|
+
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
|
165
|
+
child.props.selected =
|
|
166
|
+
normalizedProps.value.indexOf(child.props.value) != -1;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Adding support for defaultValue in select tag
|
|
171
|
+
if (type == 'select' && normalizedProps.defaultValue != null) {
|
|
172
|
+
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
|
173
|
+
if (normalizedProps.multiple) {
|
|
174
|
+
child.props.selected =
|
|
175
|
+
normalizedProps.defaultValue.indexOf(child.props.value) != -1;
|
|
176
|
+
} else {
|
|
177
|
+
child.props.selected =
|
|
178
|
+
normalizedProps.defaultValue == child.props.value;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
vnode.props = normalizedProps;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (type && props.class != props.className) {
|
|
187
|
+
classNameDescriptor.enumerable = 'className' in props;
|
|
188
|
+
if (props.className != null) normalizedProps.class = props.className;
|
|
189
|
+
Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
|
193
|
+
|
|
194
|
+
if (oldVNodeHook) oldVNodeHook(vnode);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Only needed for react-relay
|
|
198
|
+
let currentComponent;
|
|
199
|
+
const oldBeforeRender = options._render;
|
|
200
|
+
options._render = function(vnode) {
|
|
201
|
+
if (oldBeforeRender) {
|
|
202
|
+
oldBeforeRender(vnode);
|
|
203
|
+
}
|
|
204
|
+
currentComponent = vnode._component;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// This is a very very private internal function for React it
|
|
208
|
+
// is used to sort-of do runtime dependency injection. So far
|
|
209
|
+
// only `react-relay` makes use of it. It uses it to read the
|
|
210
|
+
// context value.
|
|
211
|
+
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
|
212
|
+
ReactCurrentDispatcher: {
|
|
213
|
+
current: {
|
|
214
|
+
readContext(context) {
|
|
215
|
+
return currentComponent._globalContext[context._id].props.value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|