@bpmn-io/properties-panel 0.9.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 +11 -0
- 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 -166
- 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 -83
- 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/Description.js +0 -26
- package/lib/components/entries/Description.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 -110
- package/lib/components/entries/NumberField.js.map +0 -1
- package/lib/components/entries/Select.js +0 -110
- 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 -98
- package/lib/components/entries/TextArea.js.map +0 -1
- package/lib/components/entries/TextField.js +0 -123
- package/lib/components/entries/TextField.js.map +0 -1
- package/lib/components/entries/ToggleSwitch.js +0 -91
- 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/DescriptionContext.js +0 -7
- package/lib/context/DescriptionContext.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 -3
- 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 -5
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useDescriptionContext.js +0 -25
- package/lib/hooks/useDescriptionContext.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
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import Description from './Description';
|
|
2
|
-
import { useEffect, useMemo, useState } from 'preact/hooks';
|
|
3
|
-
import classnames from 'classnames';
|
|
4
|
-
import { usePrevious } from '../../hooks';
|
|
5
|
-
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
6
|
-
import { jsxs as _jsxs } from "preact/jsx-runtime";
|
|
7
|
-
|
|
8
|
-
function Textfield(props) {
|
|
9
|
-
const {
|
|
10
|
-
debounce,
|
|
11
|
-
disabled = false,
|
|
12
|
-
id,
|
|
13
|
-
label,
|
|
14
|
-
onInput,
|
|
15
|
-
value = ''
|
|
16
|
-
} = props;
|
|
17
|
-
const handleInput = useMemo(() => {
|
|
18
|
-
return debounce(({
|
|
19
|
-
target
|
|
20
|
-
}) => onInput(target.value.length ? target.value : undefined));
|
|
21
|
-
}, [onInput, debounce]);
|
|
22
|
-
return _jsxs("div", {
|
|
23
|
-
class: "bio-properties-panel-textfield",
|
|
24
|
-
children: [_jsx("label", {
|
|
25
|
-
for: prefixId(id),
|
|
26
|
-
class: "bio-properties-panel-label",
|
|
27
|
-
children: label
|
|
28
|
-
}), _jsx("input", {
|
|
29
|
-
id: prefixId(id),
|
|
30
|
-
type: "text",
|
|
31
|
-
name: id,
|
|
32
|
-
spellCheck: "false",
|
|
33
|
-
autoComplete: "off",
|
|
34
|
-
disabled: disabled,
|
|
35
|
-
class: "bio-properties-panel-input",
|
|
36
|
-
onInput: handleInput,
|
|
37
|
-
onFocus: props.onFocus,
|
|
38
|
-
onBlur: props.onBlur,
|
|
39
|
-
value: value || ''
|
|
40
|
-
})]
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @param {Object} props
|
|
45
|
-
* @param {Object} props.element
|
|
46
|
-
* @param {String} props.id
|
|
47
|
-
* @param {String} props.description
|
|
48
|
-
* @param {Boolean} props.debounce
|
|
49
|
-
* @param {Boolean} props.disabled
|
|
50
|
-
* @param {String} props.label
|
|
51
|
-
* @param {Function} props.getValue
|
|
52
|
-
* @param {Function} props.setValue
|
|
53
|
-
* @param {Function} props.validate
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export default function TextfieldEntry(props) {
|
|
58
|
-
const {
|
|
59
|
-
element,
|
|
60
|
-
id,
|
|
61
|
-
description,
|
|
62
|
-
debounce,
|
|
63
|
-
disabled,
|
|
64
|
-
label,
|
|
65
|
-
getValue,
|
|
66
|
-
setValue,
|
|
67
|
-
validate
|
|
68
|
-
} = props;
|
|
69
|
-
const [error, setError] = useState(null);
|
|
70
|
-
const [invalidValueCache, setInvalidValueCache] = useState(null);
|
|
71
|
-
let value = getValue(element);
|
|
72
|
-
const prevValue = usePrevious(value); // validate again when value prop changed
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
const err = validate ? validate(value) : null;
|
|
76
|
-
setError(err);
|
|
77
|
-
}, [value]); // validate on change
|
|
78
|
-
|
|
79
|
-
const handleChange = newValue => {
|
|
80
|
-
const err = validate ? validate(newValue) : null;
|
|
81
|
-
|
|
82
|
-
if (err) {
|
|
83
|
-
setInvalidValueCache(newValue);
|
|
84
|
-
} else {
|
|
85
|
-
setValue(newValue);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
setError(err);
|
|
89
|
-
}; // keep showing invalid value on errors, although it was not set
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (prevValue === value && error) {
|
|
93
|
-
value = invalidValueCache;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return _jsxs("div", {
|
|
97
|
-
class: classnames('bio-properties-panel-entry', error ? 'has-error' : ''),
|
|
98
|
-
"data-entry-id": id,
|
|
99
|
-
children: [_jsx(Textfield, {
|
|
100
|
-
id: id,
|
|
101
|
-
label: label,
|
|
102
|
-
value: value,
|
|
103
|
-
onInput: handleChange,
|
|
104
|
-
debounce: debounce,
|
|
105
|
-
disabled: disabled
|
|
106
|
-
}), _jsx(Description, {
|
|
107
|
-
forId: id,
|
|
108
|
-
element: element,
|
|
109
|
-
value: description
|
|
110
|
-
}), error && _jsx("div", {
|
|
111
|
-
class: "bio-properties-panel-error",
|
|
112
|
-
children: error
|
|
113
|
-
})]
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
export function isEdited(node) {
|
|
117
|
-
return node && !!node.value;
|
|
118
|
-
} // helpers /////////////////
|
|
119
|
-
|
|
120
|
-
function prefixId(id) {
|
|
121
|
-
return `bio-properties-panel-${id}`;
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=TextField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/entries/TextField.js"],"names":["Description","useEffect","useMemo","useState","classnames","usePrevious","Textfield","props","debounce","disabled","id","label","onInput","value","handleInput","target","length","undefined","prefixId","onFocus","onBlur","TextfieldEntry","element","description","getValue","setValue","validate","error","setError","invalidValueCache","setInvalidValueCache","prevValue","err","handleChange","newValue","isEdited","node"],"mappings":"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","sourcesContent":["import Description from './Description';\n\nimport {\n useEffect,\n useMemo,\n useState\n} from 'preact/hooks';\n\nimport classnames from 'classnames';\n\nimport {\n usePrevious\n} from '../../hooks';\n\n\nfunction Textfield(props) {\n\n const {\n debounce,\n disabled = false,\n id,\n label,\n onInput,\n value = ''\n } = props;\n\n const handleInput = useMemo(() => {\n return debounce(({ target }) => onInput(target.value.length ? target.value : undefined));\n }, [ onInput, debounce ]);\n\n return (\n <div class=\"bio-properties-panel-textfield\">\n <label for={ prefixId(id) } class=\"bio-properties-panel-label\">{ label }</label>\n <input\n id={ prefixId(id) }\n type=\"text\"\n name={ id }\n spellCheck=\"false\"\n autoComplete=\"off\"\n disabled={ disabled }\n class=\"bio-properties-panel-input\"\n onInput={ handleInput }\n onFocus={ props.onFocus }\n onBlur={ props.onBlur }\n value={ value || '' } />\n </div>\n );\n}\n\n/**\n * @param {Object} props\n * @param {Object} props.element\n * @param {String} props.id\n * @param {String} props.description\n * @param {Boolean} props.debounce\n * @param {Boolean} props.disabled\n * @param {String} props.label\n * @param {Function} props.getValue\n * @param {Function} props.setValue\n * @param {Function} props.validate\n */\nexport default function TextfieldEntry(props) {\n const {\n element,\n id,\n description,\n debounce,\n disabled,\n label,\n getValue,\n setValue,\n validate\n } = props;\n\n const [ error, setError ] = useState(null);\n const [ invalidValueCache, setInvalidValueCache ] = useState(null);\n\n let value = getValue(element);\n const prevValue = usePrevious(value);\n\n // validate again when value prop changed\n useEffect(() => {\n const err = validate ? validate(value) : null;\n setError(err);\n }, [ value ]);\n\n // validate on change\n const handleChange = (newValue) => {\n const err = validate ? validate(newValue) : null;\n\n if (err) {\n setInvalidValueCache(newValue);\n } else {\n setValue(newValue);\n }\n\n setError(err);\n };\n\n // keep showing invalid value on errors, although it was not set\n if (prevValue === value && error) {\n value = invalidValueCache;\n }\n\n return (\n <div class={ classnames(\n 'bio-properties-panel-entry',\n error ? 'has-error' : '')\n } data-entry-id={ id }>\n <Textfield id={ id } label={ label } value={ value } onInput={ handleChange } debounce={ debounce } disabled={ disabled } />\n <Description forId={ id } element={ element } value={ description } />\n { error && <div class=\"bio-properties-panel-error\">{ error }</div> }\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.value;\n}\n\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"TextField.js"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import Description from './Description';
|
|
2
|
-
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
3
|
-
import { jsxs as _jsxs } from "preact/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
function ToggleSwitch(props) {
|
|
6
|
-
const {
|
|
7
|
-
id,
|
|
8
|
-
label,
|
|
9
|
-
onInput,
|
|
10
|
-
value,
|
|
11
|
-
switcherLabel
|
|
12
|
-
} = props;
|
|
13
|
-
|
|
14
|
-
const handleInput = async () => {
|
|
15
|
-
onInput(!value);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return _jsxs("div", {
|
|
19
|
-
class: "bio-properties-panel-toggle-switch",
|
|
20
|
-
children: [_jsx("label", {
|
|
21
|
-
class: "bio-properties-panel-label",
|
|
22
|
-
for: prefixId(id),
|
|
23
|
-
children: label
|
|
24
|
-
}), _jsxs("div", {
|
|
25
|
-
class: "bio-properties-panel-field-wrapper",
|
|
26
|
-
children: [_jsxs("label", {
|
|
27
|
-
class: "bio-properties-panel-toggle-switch__switcher",
|
|
28
|
-
children: [_jsx("input", {
|
|
29
|
-
id: prefixId(id),
|
|
30
|
-
class: "bio-properties-panel-input",
|
|
31
|
-
type: "checkbox",
|
|
32
|
-
name: id,
|
|
33
|
-
onInput: handleInput,
|
|
34
|
-
checked: value
|
|
35
|
-
}), _jsx("span", {
|
|
36
|
-
class: "bio-properties-panel-toggle-switch__slider"
|
|
37
|
-
})]
|
|
38
|
-
}), _jsx("p", {
|
|
39
|
-
class: "bio-properties-panel-toggle-switch__label",
|
|
40
|
-
children: switcherLabel
|
|
41
|
-
})]
|
|
42
|
-
})]
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @param {Object} props
|
|
47
|
-
* @param {Object} props.element
|
|
48
|
-
* @param {String} props.id
|
|
49
|
-
* @param {String} props.description
|
|
50
|
-
* @param {String} props.label
|
|
51
|
-
* @param {String} props.switcherLabel
|
|
52
|
-
* @param {Function} props.getValue
|
|
53
|
-
* @param {Function} props.setValue
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export default function ToggleSwitchEntry(props) {
|
|
58
|
-
const {
|
|
59
|
-
element,
|
|
60
|
-
id,
|
|
61
|
-
description,
|
|
62
|
-
label,
|
|
63
|
-
switcherLabel,
|
|
64
|
-
getValue,
|
|
65
|
-
setValue
|
|
66
|
-
} = props;
|
|
67
|
-
const value = getValue(element);
|
|
68
|
-
return _jsxs("div", {
|
|
69
|
-
class: "bio-properties-panel-entry bio-properties-panel-toggle-switch-entry",
|
|
70
|
-
"data-entry-id": id,
|
|
71
|
-
children: [_jsx(ToggleSwitch, {
|
|
72
|
-
id: id,
|
|
73
|
-
label: label,
|
|
74
|
-
value: value,
|
|
75
|
-
onInput: setValue,
|
|
76
|
-
switcherLabel: switcherLabel
|
|
77
|
-
}), _jsx(Description, {
|
|
78
|
-
forId: id,
|
|
79
|
-
element: element,
|
|
80
|
-
value: description
|
|
81
|
-
})]
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
export function isEdited(node) {
|
|
85
|
-
return node && !!node.checked;
|
|
86
|
-
} // helpers /////////////////
|
|
87
|
-
|
|
88
|
-
function prefixId(id) {
|
|
89
|
-
return `bio-properties-panel-${id}`;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=ToggleSwitch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/entries/ToggleSwitch.js"],"names":["Description","ToggleSwitch","props","id","label","onInput","value","switcherLabel","handleInput","prefixId","ToggleSwitchEntry","element","description","getValue","setValue","isEdited","node","checked"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,eAAxB;;;;AAEA,SAASC,YAAT,CAAsBC,KAAtB,EAA6B;AAC3B,QAAM;AACJC,IAAAA,EADI;AAEJC,IAAAA,KAFI;AAGJC,IAAAA,OAHI;AAIJC,IAAAA,KAJI;AAKJC,IAAAA;AALI,MAMFL,KANJ;;AAQA,QAAMM,WAAW,GAAG,YAAY;AAC9BH,IAAAA,OAAO,CAAC,CAACC,KAAF,CAAP;AACD,GAFD;;AAIA,SACE;AAAK,IAAA,KAAK,EAAC,oCAAX;AAAA,eACE;AAAO,MAAA,KAAK,EAAC,4BAAb;AACE,MAAA,GAAG,EAAGG,QAAQ,CAACN,EAAD,CADhB;AAAA,gBAEIC;AAFJ,MADF,EAKE;AAAK,MAAA,KAAK,EAAC,oCAAX;AAAA,iBACE;AAAO,QAAA,KAAK,EAAC,8CAAb;AAAA,mBACE;AACE,UAAA,EAAE,EAAGK,QAAQ,CAACN,EAAD,CADf;AAEE,UAAA,KAAK,EAAC,4BAFR;AAGE,UAAA,IAAI,EAAC,UAHP;AAIE,UAAA,IAAI,EAAGA,EAJT;AAKE,UAAA,OAAO,EAAGK,WALZ;AAME,UAAA,OAAO,EAAGF;AANZ,UADF,EAQE;AAAM,UAAA,KAAK,EAAC;AAAZ,UARF;AAAA,QADF,EAWE;AAAG,QAAA,KAAK,EAAC,2CAAT;AAAA,kBAAuDC;AAAvD,QAXF;AAAA,MALF;AAAA,IADF;AAqBD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASG,iBAAT,CAA2BR,KAA3B,EAAkC;AAC/C,QAAM;AACJS,IAAAA,OADI;AAEJR,IAAAA,EAFI;AAGJS,IAAAA,WAHI;AAIJR,IAAAA,KAJI;AAKJG,IAAAA,aALI;AAMJM,IAAAA,QANI;AAOJC,IAAAA;AAPI,MAQFZ,KARJ;AAUA,QAAMI,KAAK,GAAGO,QAAQ,CAACF,OAAD,CAAtB;AACA,SACE;AAAK,IAAA,KAAK,EAAC,qEAAX;AAAiF,qBAAgBR,EAAjG;AAAA,eACE,KAAC,YAAD;AAAc,MAAA,EAAE,EAAGA,EAAnB;AAAwB,MAAA,KAAK,EAAGC,KAAhC;AAAwC,MAAA,KAAK,EAAGE,KAAhD;AAAwD,MAAA,OAAO,EAAGQ,QAAlE;AAA6E,MAAA,aAAa,EAAGP;AAA7F,MADF,EAEE,KAAC,WAAD;AAAa,MAAA,KAAK,EAAGJ,EAArB;AAA0B,MAAA,OAAO,EAAGQ,OAApC;AAA8C,MAAA,KAAK,EAAGC;AAAtD,MAFF;AAAA,IADF;AAMD;AAED,OAAO,SAASG,QAAT,CAAkBC,IAAlB,EAAwB;AAC7B,SAAOA,IAAI,IAAI,CAAC,CAACA,IAAI,CAACC,OAAtB;AACD,C,CAGD;;AAEA,SAASR,QAAT,CAAkBN,EAAlB,EAAsB;AACpB,SAAQ,wBAAwBA,EAAI,EAApC;AACD","sourcesContent":["import Description from './Description';\n\nfunction ToggleSwitch(props) {\n const {\n id,\n label,\n onInput,\n value,\n switcherLabel\n } = props;\n\n const handleInput = async () => {\n onInput(!value);\n };\n\n return (\n <div class=\"bio-properties-panel-toggle-switch\">\n <label class=\"bio-properties-panel-label\"\n for={ prefixId(id) }>\n { label }\n </label>\n <div class=\"bio-properties-panel-field-wrapper\">\n <label class=\"bio-properties-panel-toggle-switch__switcher\">\n <input\n id={ prefixId(id) }\n class=\"bio-properties-panel-input\"\n type=\"checkbox\"\n name={ id }\n onInput={ handleInput }\n checked={ value } />\n <span class=\"bio-properties-panel-toggle-switch__slider\" />\n </label>\n <p class=\"bio-properties-panel-toggle-switch__label\">{ switcherLabel }</p>\n </div>\n </div>\n );\n}\n\n/**\n * @param {Object} props\n * @param {Object} props.element\n * @param {String} props.id\n * @param {String} props.description\n * @param {String} props.label\n * @param {String} props.switcherLabel\n * @param {Function} props.getValue\n * @param {Function} props.setValue\n */\nexport default function ToggleSwitchEntry(props) {\n const {\n element,\n id,\n description,\n label,\n switcherLabel,\n getValue,\n setValue\n } = props;\n\n const value = getValue(element);\n return (\n <div class=\"bio-properties-panel-entry bio-properties-panel-toggle-switch-entry\" data-entry-id={ id }>\n <ToggleSwitch id={ id } label={ label } value={ value } onInput={ setValue } switcherLabel={ switcherLabel } />\n <Description forId={ id } element={ element } value={ description } />\n </div>\n );\n}\n\nexport function isEdited(node) {\n return node && !!node.checked;\n}\n\n\n// helpers /////////////////\n\nfunction prefixId(id) {\n return `bio-properties-panel-${ id }`;\n}\n"],"file":"ToggleSwitch.js"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
var ArrowIcon = function ArrowIcon(props) {
|
|
5
|
-
return _jsx("svg", { ...props,
|
|
6
|
-
children: _jsx("path", {
|
|
7
|
-
fillRule: "evenodd",
|
|
8
|
-
d: "m11.657 8-4.95 4.95a1 1 0 0 1-1.414-1.414L8.828 8 5.293 4.464A1 1 0 1 1 6.707 3.05L11.657 8z"
|
|
9
|
-
})
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
ArrowIcon.defaultProps = {
|
|
14
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
-
width: "16",
|
|
16
|
-
height: "16"
|
|
17
|
-
};
|
|
18
|
-
export { ArrowIcon };
|
|
19
|
-
|
|
20
|
-
var CreateIcon = function CreateIcon(props) {
|
|
21
|
-
return _jsx("svg", { ...props,
|
|
22
|
-
children: _jsx("path", {
|
|
23
|
-
fillRule: "evenodd",
|
|
24
|
-
d: "M9 13V9h4a1 1 0 0 0 0-2H9V3a1 1 0 1 0-2 0v4H3a1 1 0 1 0 0 2h4v4a1 1 0 0 0 2 0z"
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
CreateIcon.defaultProps = {
|
|
30
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
31
|
-
width: "16",
|
|
32
|
-
height: "16"
|
|
33
|
-
};
|
|
34
|
-
export { CreateIcon };
|
|
35
|
-
|
|
36
|
-
var DeleteIcon = function DeleteIcon(props) {
|
|
37
|
-
return _jsx("svg", { ...props,
|
|
38
|
-
children: _jsx("path", {
|
|
39
|
-
fillRule: "evenodd",
|
|
40
|
-
d: "M12 6v7c0 1.1-.4 1.55-1.5 1.55h-5C4.4 14.55 4 14.1 4 13V6h8zm-1.5 1.5h-5v4.3c0 .66.5 1.2 1.111 1.2H9.39c.611 0 1.111-.54 1.111-1.2V7.5zM13 3h-2l-1-1H6L5 3H3v1.5h10V3z"
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
DeleteIcon.defaultProps = {
|
|
46
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
47
|
-
width: "16",
|
|
48
|
-
height: "16"
|
|
49
|
-
};
|
|
50
|
-
export { DeleteIcon };
|
|
51
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"index.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/DescriptionContext.js"],"names":["createContext","DescriptionContext","description","getDescriptionForId"],"mappings":"AAAA,SACEA,aADF,QAEO,QAFP;AAIA,MAAMC,kBAAkB,GAAGD,aAAa,CAAC;AACvCE,EAAAA,WAAW,EAAE,EAD0B;AAEvCC,EAAAA,mBAAmB,EAAE,MAAM,CAAE;AAFU,CAAD,CAAxC;AAKA,eAAeF,kBAAf","sourcesContent":["import {\n createContext\n} from 'preact';\n\nconst DescriptionContext = createContext({\n description: {},\n getDescriptionForId: () => {}\n});\n\nexport default DescriptionContext;\n"],"file":"DescriptionContext.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/LayoutContext.js"],"names":["createContext","LayoutContext","layout","setLayout","getLayoutForKey","setLayoutForKey"],"mappings":"AAAA,SACEA,aADF,QAEO,QAFP;AAIA,MAAMC,aAAa,GAAGD,aAAa,CAAC;AAClCE,EAAAA,MAAM,EAAE,EAD0B;AAElCC,EAAAA,SAAS,EAAE,MAAM,CAAE,CAFe;AAGlCC,EAAAA,eAAe,EAAE,MAAM,CAAE,CAHS;AAIlCC,EAAAA,eAAe,EAAE,MAAM,CAAE;AAJS,CAAD,CAAnC;AAOA,eAAeJ,aAAf","sourcesContent":["import {\n createContext\n} from 'preact';\n\nconst LayoutContext = createContext({\n layout: {},\n setLayout: () => {},\n getLayoutForKey: () => {},\n setLayoutForKey: () => {}\n});\n\nexport default LayoutContext;"],"file":"LayoutContext.js"}
|
package/lib/context/index.js
DELETED
package/lib/context/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/index.js"],"names":["default","DescriptionContext","LayoutContext"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAApB,QAA8C,sBAA9C;AACA,SAASD,OAAO,IAAIE,aAApB,QAAyC,iBAAzC","sourcesContent":["export { default as DescriptionContext } from './DescriptionContext';\nexport { default as LayoutContext } from './LayoutContext';\n"],"file":"index.js"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { debounce, isNumber } from 'min-dash';
|
|
2
|
-
const DEFAULT_DEBOUNCE_TIME = 300;
|
|
3
|
-
export default function debounceInput(debounceDelay) {
|
|
4
|
-
return function _debounceInput(fn) {
|
|
5
|
-
if (debounceDelay !== false) {
|
|
6
|
-
var debounceTime = isNumber(debounceDelay) ? debounceDelay : DEFAULT_DEBOUNCE_TIME;
|
|
7
|
-
return debounce(fn, debounceTime);
|
|
8
|
-
} else {
|
|
9
|
-
return fn;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
debounceInput.$inject = ['config.debounceInput'];
|
|
14
|
-
//# sourceMappingURL=debounceInput.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/debounce-input/debounceInput.js"],"names":["debounce","isNumber","DEFAULT_DEBOUNCE_TIME","debounceInput","debounceDelay","_debounceInput","fn","debounceTime","$inject"],"mappings":"AAAA,SACEA,QADF,EAEEC,QAFF,QAGO,UAHP;AAKA,MAAMC,qBAAqB,GAAG,GAA9B;AAEA,eAAe,SAASC,aAAT,CAAuBC,aAAvB,EAAsC;AACnD,SAAO,SAASC,cAAT,CAAwBC,EAAxB,EAA4B;AACjC,QAAIF,aAAa,KAAK,KAAtB,EAA6B;AAE3B,UAAIG,YAAY,GACdN,QAAQ,CAACG,aAAD,CAAR,GACEA,aADF,GAEEF,qBAHJ;AAKA,aAAOF,QAAQ,CAACM,EAAD,EAAKC,YAAL,CAAf;AACD,KARD,MAQO;AACL,aAAOD,EAAP;AACD;AACF,GAZD;AAaD;AAEDH,aAAa,CAACK,OAAd,GAAwB,CAAE,sBAAF,CAAxB","sourcesContent":["import {\n debounce,\n isNumber\n} from 'min-dash';\n\nconst DEFAULT_DEBOUNCE_TIME = 300;\n\nexport default function debounceInput(debounceDelay) {\n return function _debounceInput(fn) {\n if (debounceDelay !== false) {\n\n var debounceTime =\n isNumber(debounceDelay) ?\n debounceDelay :\n DEFAULT_DEBOUNCE_TIME;\n\n return debounce(fn, debounceTime);\n } else {\n return fn;\n }\n };\n}\n\ndebounceInput.$inject = [ 'config.debounceInput' ];\n"],"file":"debounceInput.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/debounce-input/index.js"],"names":["debounceInput"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AAEA,eAAe;AACbA,EAAAA,aAAa,EAAE,CAAE,SAAF,EAAaA,aAAb;AADF,CAAf","sourcesContent":["import debounceInput from './debounceInput';\n\nexport default {\n debounceInput: [ 'factory', debounceInput ]\n};\n"],"file":"index.js"}
|
package/lib/hooks/index.js
DELETED
package/lib/hooks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/index.js"],"names":["default","usePrevious","useKeyFactory","useLayoutState","useDescriptionContext"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,qBAAT,QAAsC,yBAAtC","sourcesContent":["export { default as usePrevious } from './usePrevious';\nexport { useKeyFactory } from './useKeyFactory';\nexport { useLayoutState } from './useLayoutState';\nexport { useDescriptionContext } from './useDescriptionContext';\n"],"file":"index.js"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'preact/hooks';
|
|
2
|
-
import { DescriptionContext } from '../context';
|
|
3
|
-
/**
|
|
4
|
-
* Accesses the global DescriptionContext and returns a description for a given id and element.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```jsx
|
|
8
|
-
* function TextField(props) {
|
|
9
|
-
* const description = useDescriptionContext('input1', element);
|
|
10
|
-
* }
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @param {string} id
|
|
14
|
-
* @param {djs.model.Base} element
|
|
15
|
-
*
|
|
16
|
-
* @returns {string}
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export function useDescriptionContext(id, element) {
|
|
20
|
-
const {
|
|
21
|
-
getDescriptionForId
|
|
22
|
-
} = useContext(DescriptionContext);
|
|
23
|
-
return getDescriptionForId(id, element);
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=useDescriptionContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useDescriptionContext.js"],"names":["useContext","DescriptionContext","useDescriptionContext","id","element","getDescriptionForId"],"mappings":"AAAA,SACEA,UADF,QAEO,cAFP;AAIA,SACEC,kBADF,QAEO,YAFP;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAA+BC,EAA/B,EAAmCC,OAAnC,EAA4C;AACjD,QAAM;AACJC,IAAAA;AADI,MAEFL,UAAU,CAACC,kBAAD,CAFd;AAIA,SAAOI,mBAAmB,CAACF,EAAD,EAAKC,OAAL,CAA1B;AACD","sourcesContent":["import {\n useContext\n} from 'preact/hooks';\n\nimport {\n DescriptionContext\n} from '../context';\n\n/**\n * Accesses the global DescriptionContext and returns a description for a given id and element.\n *\n * @example\n * ```jsx\n * function TextField(props) {\n * const description = useDescriptionContext('input1', element);\n * }\n * ```\n *\n * @param {string} id\n * @param {djs.model.Base} element\n *\n * @returns {string}\n */\nexport function useDescriptionContext(id, element) {\n const {\n getDescriptionForId\n } = useContext(DescriptionContext);\n\n return getDescriptionForId(id, element);\n}\n"],"file":"useDescriptionContext.js"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'preact/hooks';
|
|
2
|
-
const KEY_LENGTH = 6;
|
|
3
|
-
/**
|
|
4
|
-
* Create a persistent key factory for plain objects without id.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```jsx
|
|
8
|
-
* function List({ objects }) {
|
|
9
|
-
* const getKey = useKeyFactory();
|
|
10
|
-
* return (<ol>{
|
|
11
|
-
* objects.map(obj => {
|
|
12
|
-
* const key = getKey(obj);
|
|
13
|
-
* return <li key={key}>obj.name</li>
|
|
14
|
-
* })
|
|
15
|
-
* }</ol>);
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param {any[]} dependencies
|
|
20
|
-
* @returns {(element: object) => string}
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export function useKeyFactory(dependencies = []) {
|
|
24
|
-
const map = useMemo(() => new Map(), dependencies);
|
|
25
|
-
|
|
26
|
-
const getKey = el => {
|
|
27
|
-
let key = map.get(el);
|
|
28
|
-
|
|
29
|
-
if (!key) {
|
|
30
|
-
key = Math.random().toString().slice(-KEY_LENGTH);
|
|
31
|
-
map.set(el, key);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return key;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return getKey;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=useKeyFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useKeyFactory.js"],"names":["useMemo","KEY_LENGTH","useKeyFactory","dependencies","map","Map","getKey","el","key","get","Math","random","toString","slice","set"],"mappings":"AAAA,SAASA,OAAT,QAAwB,cAAxB;AAEA,MAAMC,UAAU,GAAG,CAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAuBC,YAAY,GAAG,EAAtC,EAA0C;AAC/C,QAAMC,GAAG,GAAGJ,OAAO,CAAC,MAAM,IAAIK,GAAJ,EAAP,EAAkBF,YAAlB,CAAnB;;AAEA,QAAMG,MAAM,GAAGC,EAAE,IAAI;AACnB,QAAIC,GAAG,GAAGJ,GAAG,CAACK,GAAJ,CAAQF,EAAR,CAAV;;AAEA,QAAI,CAACC,GAAL,EAAU;AACRA,MAAAA,GAAG,GAAGE,IAAI,CAACC,MAAL,GAAcC,QAAd,GAAyBC,KAAzB,CAA+B,CAACZ,UAAhC,CAAN;AACAG,MAAAA,GAAG,CAACU,GAAJ,CAAQP,EAAR,EAAYC,GAAZ;AACD;;AAED,WAAOA,GAAP;AACD,GATD;;AAWA,SAAOF,MAAP;AACD","sourcesContent":["import { useMemo } from 'preact/hooks';\n\nconst KEY_LENGTH = 6;\n\n/**\n * Create a persistent key factory for plain objects without id.\n *\n * @example\n * ```jsx\n * function List({ objects }) {\n * const getKey = useKeyFactory();\n * return (<ol>{\n * objects.map(obj => {\n * const key = getKey(obj);\n * return <li key={key}>obj.name</li>\n * })\n * }</ol>);\n * }\n * ```\n *\n * @param {any[]} dependencies\n * @returns {(element: object) => string}\n */\nexport function useKeyFactory(dependencies = []) {\n const map = useMemo(() => new Map(), dependencies);\n\n const getKey = el => {\n let key = map.get(el);\n\n if (!key) {\n key = Math.random().toString().slice(-KEY_LENGTH);\n map.set(el, key);\n }\n\n return key;\n };\n\n return getKey;\n}\n"],"file":"useKeyFactory.js"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useContext, useState } from 'preact/hooks';
|
|
2
|
-
import { LayoutContext } from '../context';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a state that persists in the global LayoutContext.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```jsx
|
|
8
|
-
* function Group(props) {
|
|
9
|
-
* const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);
|
|
10
|
-
* }
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @param {(string|number)[]} path
|
|
14
|
-
* @param {any} [defaultValue]
|
|
15
|
-
*
|
|
16
|
-
* @returns {[ any, Function ]}
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export function useLayoutState(path, defaultValue) {
|
|
20
|
-
const {
|
|
21
|
-
getLayoutForKey,
|
|
22
|
-
setLayoutForKey
|
|
23
|
-
} = useContext(LayoutContext);
|
|
24
|
-
const layoutForKey = getLayoutForKey(path, defaultValue);
|
|
25
|
-
const [value, set] = useState(layoutForKey);
|
|
26
|
-
|
|
27
|
-
const setState = newValue => {
|
|
28
|
-
// (1) set component state
|
|
29
|
-
set(newValue); // (2) set context
|
|
30
|
-
|
|
31
|
-
setLayoutForKey(path, newValue);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return [value, setState];
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=useLayoutState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useLayoutState.js"],"names":["useContext","useState","LayoutContext","useLayoutState","path","defaultValue","getLayoutForKey","setLayoutForKey","layoutForKey","value","set","setState","newValue"],"mappings":"AAAA,SACEA,UADF,EAEEC,QAFF,QAGO,cAHP;AAKA,SACEC,aADF,QAEO,YAFP;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,cAAT,CAAwBC,IAAxB,EAA8BC,YAA9B,EAA4C;AACjD,QAAM;AACJC,IAAAA,eADI;AAEJC,IAAAA;AAFI,MAGFP,UAAU,CAACE,aAAD,CAHd;AAKA,QAAMM,YAAY,GAAGF,eAAe,CAACF,IAAD,EAAOC,YAAP,CAApC;AACA,QAAM,CAAEI,KAAF,EAASC,GAAT,IAAiBT,QAAQ,CAACO,YAAD,CAA/B;;AAEA,QAAMG,QAAQ,GAAIC,QAAD,IAAc;AAE7B;AACAF,IAAAA,GAAG,CAACE,QAAD,CAAH,CAH6B,CAK7B;;AACAL,IAAAA,eAAe,CAACH,IAAD,EAAOQ,QAAP,CAAf;AACD,GAPD;;AASA,SAAO,CAAEH,KAAF,EAASE,QAAT,CAAP;AACD","sourcesContent":["import {\n useContext,\n useState\n} from 'preact/hooks';\n\nimport {\n LayoutContext\n} from '../context';\n\n/**\n * Creates a state that persists in the global LayoutContext.\n *\n * @example\n * ```jsx\n * function Group(props) {\n * const [ open, setOpen ] = useLayoutState([ 'groups', 'foo', 'open' ], false);\n * }\n * ```\n *\n * @param {(string|number)[]} path\n * @param {any} [defaultValue]\n *\n * @returns {[ any, Function ]}\n */\nexport function useLayoutState(path, defaultValue) {\n const {\n getLayoutForKey,\n setLayoutForKey\n } = useContext(LayoutContext);\n\n const layoutForKey = getLayoutForKey(path, defaultValue);\n const [ value, set ] = useState(layoutForKey);\n\n const setState = (newValue) => {\n\n // (1) set component state\n set(newValue);\n\n // (2) set context\n setLayoutForKey(path, newValue);\n };\n\n return [ value, setState ];\n}\n"],"file":"useLayoutState.js"}
|
package/lib/hooks/usePrevious.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'preact/hooks';
|
|
2
|
-
/**
|
|
3
|
-
* @pinussilvestrus: we need to introduce our own hook to persist the previous
|
|
4
|
-
* state on updates.
|
|
5
|
-
*
|
|
6
|
-
* cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export default function usePrevious(value) {
|
|
10
|
-
const ref = useRef();
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
ref.current = value;
|
|
13
|
-
});
|
|
14
|
-
return ref.current;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/usePrevious.js"],"names":["useEffect","useRef","usePrevious","value","ref","current"],"mappings":"AAAA,SACEA,SADF,EAEEC,MAFF,QAGO,cAHP;AAKA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AACzC,QAAMC,GAAG,GAAGH,MAAM,EAAlB;AACAD,EAAAA,SAAS,CAAC,MAAM;AACdI,IAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACD,GAFQ,CAAT;AAGA,SAAOC,GAAG,CAACC,OAAX;AACD","sourcesContent":["import {\n useEffect,\n useRef\n} from 'preact/hooks';\n\n/**\n * @pinussilvestrus: we need to introduce our own hook to persist the previous\n * state on updates.\n *\n * cf. https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state\n */\n\nexport default function usePrevious(value) {\n const ref = useRef();\n useEffect(() => {\n ref.current = value;\n });\n return ref.current;\n}"],"file":"usePrevious.js"}
|
package/lib/index.js
DELETED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,mBAAxB","sourcesContent":["export { default } from './PropertiesPanel';"],"file":"index.js"}
|