@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.
Files changed (175) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/assets/properties-panel.css +42 -1
  3. package/dist/index.esm.js +1607 -0
  4. package/dist/index.esm.js.map +1 -0
  5. package/dist/index.js +1648 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +16 -7
  8. package/preact/LICENSE +21 -0
  9. package/preact/README.md +185 -0
  10. package/preact/compat/dist/compat.js +2 -0
  11. package/preact/compat/dist/compat.js.map +1 -0
  12. package/preact/compat/dist/compat.mjs +2 -0
  13. package/preact/compat/dist/compat.module.js +2 -0
  14. package/preact/compat/dist/compat.module.js.map +1 -0
  15. package/preact/compat/dist/compat.umd.js +2 -0
  16. package/preact/compat/dist/compat.umd.js.map +1 -0
  17. package/preact/compat/jsx-dev-runtime.js +1 -0
  18. package/preact/compat/jsx-dev-runtime.mjs +1 -0
  19. package/preact/compat/jsx-runtime.js +1 -0
  20. package/preact/compat/jsx-runtime.mjs +1 -0
  21. package/preact/compat/package.json +19 -0
  22. package/preact/compat/server.js +15 -0
  23. package/preact/compat/server.mjs +4 -0
  24. package/preact/compat/src/Children.js +21 -0
  25. package/preact/compat/src/PureComponent.js +15 -0
  26. package/preact/compat/src/forwardRef.js +51 -0
  27. package/preact/compat/src/index.d.ts +140 -0
  28. package/preact/compat/src/index.js +175 -0
  29. package/preact/compat/src/internal.d.ts +47 -0
  30. package/preact/compat/src/memo.js +34 -0
  31. package/preact/compat/src/portals.js +80 -0
  32. package/preact/compat/src/render.js +219 -0
  33. package/preact/compat/src/scheduler.js +24 -0
  34. package/preact/compat/src/suspense-list.d.ts +14 -0
  35. package/preact/compat/src/suspense-list.js +126 -0
  36. package/preact/compat/src/suspense.d.ts +15 -0
  37. package/preact/compat/src/suspense.js +270 -0
  38. package/preact/compat/src/util.js +28 -0
  39. package/preact/compat/test-utils.js +1 -0
  40. package/preact/debug/dist/debug.js +2 -0
  41. package/preact/debug/dist/debug.js.map +1 -0
  42. package/preact/debug/dist/debug.mjs +2 -0
  43. package/preact/debug/dist/debug.module.js +2 -0
  44. package/preact/debug/dist/debug.module.js.map +1 -0
  45. package/preact/debug/dist/debug.umd.js +2 -0
  46. package/preact/debug/dist/debug.umd.js.map +1 -0
  47. package/preact/debug/package.json +18 -0
  48. package/preact/debug/src/check-props.js +54 -0
  49. package/preact/debug/src/component-stack.js +146 -0
  50. package/preact/debug/src/constants.js +3 -0
  51. package/preact/debug/src/debug.js +442 -0
  52. package/preact/debug/src/index.js +6 -0
  53. package/preact/debug/src/internal.d.ts +82 -0
  54. package/preact/debug/src/util.js +11 -0
  55. package/preact/devtools/dist/devtools.js +2 -0
  56. package/preact/devtools/dist/devtools.js.map +1 -0
  57. package/preact/devtools/dist/devtools.mjs +2 -0
  58. package/preact/devtools/dist/devtools.module.js +2 -0
  59. package/preact/devtools/dist/devtools.module.js.map +1 -0
  60. package/preact/devtools/dist/devtools.umd.js +2 -0
  61. package/preact/devtools/dist/devtools.umd.js.map +1 -0
  62. package/preact/devtools/package.json +16 -0
  63. package/preact/devtools/src/devtools.js +10 -0
  64. package/preact/devtools/src/index.d.ts +8 -0
  65. package/preact/devtools/src/index.js +15 -0
  66. package/preact/dist/preact.js +2 -0
  67. package/preact/dist/preact.js.map +1 -0
  68. package/preact/dist/preact.min.js +2 -0
  69. package/preact/dist/preact.min.js.map +1 -0
  70. package/preact/dist/preact.mjs +2 -0
  71. package/preact/dist/preact.module.js +2 -0
  72. package/preact/dist/preact.module.js.map +1 -0
  73. package/preact/dist/preact.umd.js +2 -0
  74. package/preact/dist/preact.umd.js.map +1 -0
  75. package/preact/hooks/dist/hooks.js +2 -0
  76. package/preact/hooks/dist/hooks.js.map +1 -0
  77. package/preact/hooks/dist/hooks.mjs +2 -0
  78. package/preact/hooks/dist/hooks.module.js +2 -0
  79. package/preact/hooks/dist/hooks.module.js.map +1 -0
  80. package/preact/hooks/dist/hooks.umd.js +2 -0
  81. package/preact/hooks/dist/hooks.umd.js.map +1 -0
  82. package/preact/hooks/package.json +26 -0
  83. package/preact/hooks/src/index.d.ts +130 -0
  84. package/preact/hooks/src/index.js +386 -0
  85. package/preact/hooks/src/internal.d.ts +75 -0
  86. package/preact/jsx-runtime/dist/jsxRuntime.js +2 -0
  87. package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -0
  88. package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -0
  89. package/preact/jsx-runtime/dist/jsxRuntime.module.js +2 -0
  90. package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -0
  91. package/preact/jsx-runtime/dist/jsxRuntime.umd.js +2 -0
  92. package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -0
  93. package/preact/jsx-runtime/package.json +19 -0
  94. package/preact/jsx-runtime/src/index.d.ts +50 -0
  95. package/preact/jsx-runtime/src/index.js +72 -0
  96. package/preact/package.json +268 -0
  97. package/preact/src/cjs.js +3 -0
  98. package/preact/src/clone-element.js +39 -0
  99. package/preact/src/component.js +225 -0
  100. package/preact/src/constants.js +3 -0
  101. package/preact/src/create-context.js +68 -0
  102. package/preact/src/create-element.js +100 -0
  103. package/preact/src/diff/catch-error.js +38 -0
  104. package/preact/src/diff/children.js +347 -0
  105. package/preact/src/diff/index.js +516 -0
  106. package/preact/src/diff/props.js +158 -0
  107. package/preact/src/index.d.ts +310 -0
  108. package/preact/src/index.js +13 -0
  109. package/preact/src/internal.d.ts +147 -0
  110. package/preact/src/jsx.d.ts +955 -0
  111. package/preact/src/options.js +17 -0
  112. package/preact/src/render.js +74 -0
  113. package/preact/src/util.js +23 -0
  114. package/preact/test-utils/dist/testUtils.js +2 -0
  115. package/preact/test-utils/dist/testUtils.js.map +1 -0
  116. package/preact/test-utils/dist/testUtils.mjs +2 -0
  117. package/preact/test-utils/dist/testUtils.module.js +2 -0
  118. package/preact/test-utils/dist/testUtils.module.js.map +1 -0
  119. package/preact/test-utils/dist/testUtils.umd.js +2 -0
  120. package/preact/test-utils/dist/testUtils.umd.js.map +1 -0
  121. package/preact/test-utils/package.json +19 -0
  122. package/preact/test-utils/src/index.d.ts +3 -0
  123. package/preact/test-utils/src/index.js +117 -0
  124. package/lib/PropertiesPanel.js +0 -126
  125. package/lib/PropertiesPanel.js.map +0 -1
  126. package/lib/components/DropdownButton.js +0 -109
  127. package/lib/components/DropdownButton.js.map +0 -1
  128. package/lib/components/Group.js +0 -75
  129. package/lib/components/Group.js.map +0 -1
  130. package/lib/components/Header.js +0 -49
  131. package/lib/components/Header.js.map +0 -1
  132. package/lib/components/HeaderButton.js +0 -16
  133. package/lib/components/HeaderButton.js.map +0 -1
  134. package/lib/components/ListGroup.js +0 -167
  135. package/lib/components/ListGroup.js.map +0 -1
  136. package/lib/components/ListItem.js +0 -37
  137. package/lib/components/ListItem.js.map +0 -1
  138. package/lib/components/entries/Checkbox.js +0 -76
  139. package/lib/components/entries/Checkbox.js.map +0 -1
  140. package/lib/components/entries/Collapsible.js +0 -48
  141. package/lib/components/entries/Collapsible.js.map +0 -1
  142. package/lib/components/entries/List.js +0 -204
  143. package/lib/components/entries/List.js.map +0 -1
  144. package/lib/components/entries/NumberField.js +0 -108
  145. package/lib/components/entries/NumberField.js.map +0 -1
  146. package/lib/components/entries/Select.js +0 -101
  147. package/lib/components/entries/Select.js.map +0 -1
  148. package/lib/components/entries/Simple.js +0 -56
  149. package/lib/components/entries/Simple.js.map +0 -1
  150. package/lib/components/entries/TextArea.js +0 -91
  151. package/lib/components/entries/TextArea.js.map +0 -1
  152. package/lib/components/entries/TextField.js +0 -121
  153. package/lib/components/entries/TextField.js.map +0 -1
  154. package/lib/components/entries/ToggleSwitch.js +0 -87
  155. package/lib/components/entries/ToggleSwitch.js.map +0 -1
  156. package/lib/components/icons/index.js +0 -51
  157. package/lib/components/icons/index.js.map +0 -1
  158. package/lib/context/LayoutContext.js +0 -9
  159. package/lib/context/LayoutContext.js.map +0 -1
  160. package/lib/context/index.js +0 -2
  161. package/lib/context/index.js.map +0 -1
  162. package/lib/features/debounce-input/debounceInput.js +0 -14
  163. package/lib/features/debounce-input/debounceInput.js.map +0 -1
  164. package/lib/features/debounce-input/index.js +0 -5
  165. package/lib/features/debounce-input/index.js.map +0 -1
  166. package/lib/hooks/index.js +0 -4
  167. package/lib/hooks/index.js.map +0 -1
  168. package/lib/hooks/useKeyFactory.js +0 -39
  169. package/lib/hooks/useKeyFactory.js.map +0 -1
  170. package/lib/hooks/useLayoutState.js +0 -36
  171. package/lib/hooks/useLayoutState.js.map +0 -1
  172. package/lib/hooks/usePrevious.js +0 -16
  173. package/lib/hooks/usePrevious.js.map +0 -1
  174. package/lib/index.js +0 -2
  175. 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
+ };