@atlaskit/editor-plugin-extension 0.4.2 → 0.5.1
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/.eslintrc.js +26 -0
- package/CHANGELOG.md +16 -0
- package/dist/cjs/actions.js +236 -0
- package/dist/cjs/commands.js +122 -0
- package/dist/cjs/context-panel.js +269 -0
- package/dist/cjs/extension-api.js +266 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/plugin-factory.js +32 -0
- package/dist/cjs/plugin-key.js +8 -0
- package/dist/cjs/plugin.js +147 -0
- package/dist/cjs/pm-plugins/keymap.js +21 -0
- package/dist/cjs/pm-plugins/macro/actions.js +186 -0
- package/dist/cjs/pm-plugins/macro/index.js +72 -0
- package/dist/cjs/pm-plugins/macro/plugin-key.js +8 -0
- package/dist/cjs/pm-plugins/macro/types.js +5 -0
- package/dist/cjs/pm-plugins/main.js +323 -0
- package/dist/cjs/pm-plugins/unique-id.js +80 -0
- package/dist/cjs/pm-plugins/utils.js +75 -0
- package/dist/cjs/reducer.js +18 -0
- package/dist/cjs/toolbar.js +242 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +475 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +122 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanelLoader.js +23 -0
- package/dist/cjs/ui/ConfigPanel/ErrorMessage/ErrorImage.js +76 -0
- package/dist/cjs/ui/ConfigPanel/ErrorMessage/index.js +33 -0
- package/dist/cjs/ui/ConfigPanel/FieldMessages.js +105 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Boolean.js +150 -0
- package/dist/cjs/ui/ConfigPanel/Fields/CheckboxGroup.js +101 -0
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +420 -0
- package/dist/cjs/ui/ConfigPanel/Fields/CustomSelect.js +192 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Date.js +55 -0
- package/dist/cjs/ui/ConfigPanel/Fields/DateRange.js +160 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Enum.js +41 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +88 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Fieldset.js +270 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Number.js +64 -0
- package/dist/cjs/ui/ConfigPanel/Fields/RadioGroup.js +56 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Select.js +60 -0
- package/dist/cjs/ui/ConfigPanel/Fields/SelectItem.js +53 -0
- package/dist/cjs/ui/ConfigPanel/Fields/String.js +75 -0
- package/dist/cjs/ui/ConfigPanel/Fields/TabGroup.js +73 -0
- package/dist/cjs/ui/ConfigPanel/Fields/UnhandledType.js +19 -0
- package/dist/cjs/ui/ConfigPanel/Fields/UserSelect.js +268 -0
- package/dist/cjs/ui/ConfigPanel/Fields/common/RequiredIndicator.js +12 -0
- package/dist/cjs/ui/ConfigPanel/FormContent.js +231 -0
- package/dist/cjs/ui/ConfigPanel/FormErrorBoundary.js +140 -0
- package/dist/cjs/ui/ConfigPanel/Header.js +148 -0
- package/dist/cjs/ui/ConfigPanel/LoadingState.js +25 -0
- package/dist/cjs/ui/ConfigPanel/NestedForms/RemovableField.js +61 -0
- package/dist/cjs/ui/ConfigPanel/constants.js +13 -0
- package/dist/cjs/ui/ConfigPanel/index.js +9 -0
- package/dist/cjs/ui/ConfigPanel/messages.js +99 -0
- package/dist/cjs/ui/ConfigPanel/transformers.js +631 -0
- package/dist/cjs/ui/ConfigPanel/types.js +15 -0
- package/dist/cjs/ui/ConfigPanel/use-abortable-effect/index.js +56 -0
- package/dist/cjs/ui/ConfigPanel/use-state-from-promise/index.js +41 -0
- package/dist/cjs/ui/ConfigPanel/utils.js +116 -0
- package/dist/cjs/ui/SaveIndicator/SaveIndicator.js +79 -0
- package/dist/cjs/ui/SaveIndicator/messages.js +14 -0
- package/dist/cjs/ui/SaveIndicator/types.js +5 -0
- package/dist/cjs/utils.js +73 -0
- package/dist/es2019/actions.js +203 -0
- package/dist/es2019/commands.js +99 -0
- package/dist/es2019/context-panel.js +181 -0
- package/dist/es2019/extension-api.js +284 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugin-factory.js +26 -0
- package/dist/es2019/plugin-key.js +2 -0
- package/dist/es2019/plugin.js +138 -0
- package/dist/es2019/pm-plugins/keymap.js +15 -0
- package/dist/es2019/pm-plugins/macro/actions.js +152 -0
- package/dist/es2019/pm-plugins/macro/index.js +36 -0
- package/dist/es2019/pm-plugins/macro/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/macro/types.js +1 -0
- package/dist/es2019/pm-plugins/main.js +230 -0
- package/dist/es2019/pm-plugins/unique-id.js +69 -0
- package/dist/es2019/pm-plugins/utils.js +30 -0
- package/dist/es2019/reducer.js +11 -0
- package/dist/es2019/toolbar.js +236 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +415 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +100 -0
- package/dist/es2019/ui/ConfigPanel/ConfigPanelLoader.js +7 -0
- package/dist/es2019/ui/ConfigPanel/ErrorMessage/ErrorImage.js +66 -0
- package/dist/es2019/ui/ConfigPanel/ErrorMessage/index.js +25 -0
- package/dist/es2019/ui/ConfigPanel/FieldMessages.js +101 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Boolean.js +138 -0
- package/dist/es2019/ui/ConfigPanel/Fields/CheckboxGroup.js +96 -0
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +411 -0
- package/dist/es2019/ui/ConfigPanel/Fields/CustomSelect.js +132 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Date.js +50 -0
- package/dist/es2019/ui/ConfigPanel/Fields/DateRange.js +139 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Enum.js +35 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +73 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Fieldset.js +227 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Number.js +61 -0
- package/dist/es2019/ui/ConfigPanel/Fields/RadioGroup.js +40 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Select.js +50 -0
- package/dist/es2019/ui/ConfigPanel/Fields/SelectItem.js +47 -0
- package/dist/es2019/ui/ConfigPanel/Fields/String.js +67 -0
- package/dist/es2019/ui/ConfigPanel/Fields/TabGroup.js +57 -0
- package/dist/es2019/ui/ConfigPanel/Fields/UnhandledType.js +11 -0
- package/dist/es2019/ui/ConfigPanel/Fields/UserSelect.js +194 -0
- package/dist/es2019/ui/ConfigPanel/Fields/common/RequiredIndicator.js +5 -0
- package/dist/es2019/ui/ConfigPanel/FormContent.js +225 -0
- package/dist/es2019/ui/ConfigPanel/FormErrorBoundary.js +100 -0
- package/dist/es2019/ui/ConfigPanel/Header.js +140 -0
- package/dist/es2019/ui/ConfigPanel/LoadingState.js +15 -0
- package/dist/es2019/ui/ConfigPanel/NestedForms/RemovableField.js +52 -0
- package/dist/es2019/ui/ConfigPanel/constants.js +7 -0
- package/dist/es2019/ui/ConfigPanel/index.js +2 -0
- package/dist/es2019/ui/ConfigPanel/messages.js +93 -0
- package/dist/es2019/ui/ConfigPanel/transformers.js +367 -0
- package/dist/es2019/ui/ConfigPanel/types.js +9 -0
- package/dist/es2019/ui/ConfigPanel/use-abortable-effect/index.js +46 -0
- package/dist/es2019/ui/ConfigPanel/use-state-from-promise/index.js +30 -0
- package/dist/es2019/ui/ConfigPanel/utils.js +86 -0
- package/dist/es2019/ui/SaveIndicator/SaveIndicator.js +66 -0
- package/dist/es2019/ui/SaveIndicator/messages.js +8 -0
- package/dist/es2019/ui/SaveIndicator/types.js +1 -0
- package/dist/es2019/utils.js +65 -0
- package/dist/esm/actions.js +223 -0
- package/dist/esm/commands.js +113 -0
- package/dist/esm/context-panel.js +261 -0
- package/dist/esm/extension-api.js +259 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugin-factory.js +25 -0
- package/dist/esm/plugin-key.js +2 -0
- package/dist/esm/plugin.js +140 -0
- package/dist/esm/pm-plugins/keymap.js +15 -0
- package/dist/esm/pm-plugins/macro/actions.js +179 -0
- package/dist/esm/pm-plugins/macro/index.js +42 -0
- package/dist/esm/pm-plugins/macro/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/macro/types.js +1 -0
- package/dist/esm/pm-plugins/main.js +298 -0
- package/dist/esm/pm-plugins/unique-id.js +74 -0
- package/dist/esm/pm-plugins/utils.js +68 -0
- package/dist/esm/reducer.js +11 -0
- package/dist/esm/toolbar.js +235 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +465 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +112 -0
- package/dist/esm/ui/ConfigPanel/ConfigPanelLoader.js +11 -0
- package/dist/esm/ui/ConfigPanel/ErrorMessage/ErrorImage.js +68 -0
- package/dist/esm/ui/ConfigPanel/ErrorMessage/index.js +26 -0
- package/dist/esm/ui/ConfigPanel/FieldMessages.js +97 -0
- package/dist/esm/ui/ConfigPanel/Fields/Boolean.js +140 -0
- package/dist/esm/ui/ConfigPanel/Fields/CheckboxGroup.js +95 -0
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +414 -0
- package/dist/esm/ui/ConfigPanel/Fields/CustomSelect.js +182 -0
- package/dist/esm/ui/ConfigPanel/Fields/Date.js +48 -0
- package/dist/esm/ui/ConfigPanel/Fields/DateRange.js +154 -0
- package/dist/esm/ui/ConfigPanel/Fields/Enum.js +34 -0
- package/dist/esm/ui/ConfigPanel/Fields/Expand.js +77 -0
- package/dist/esm/ui/ConfigPanel/Fields/Fieldset.js +261 -0
- package/dist/esm/ui/ConfigPanel/Fields/Number.js +57 -0
- package/dist/esm/ui/ConfigPanel/Fields/RadioGroup.js +46 -0
- package/dist/esm/ui/ConfigPanel/Fields/Select.js +50 -0
- package/dist/esm/ui/ConfigPanel/Fields/SelectItem.js +45 -0
- package/dist/esm/ui/ConfigPanel/Fields/String.js +65 -0
- package/dist/esm/ui/ConfigPanel/Fields/TabGroup.js +62 -0
- package/dist/esm/ui/ConfigPanel/Fields/UnhandledType.js +10 -0
- package/dist/esm/ui/ConfigPanel/Fields/UserSelect.js +258 -0
- package/dist/esm/ui/ConfigPanel/Fields/common/RequiredIndicator.js +5 -0
- package/dist/esm/ui/ConfigPanel/FormContent.js +223 -0
- package/dist/esm/ui/ConfigPanel/FormErrorBoundary.js +133 -0
- package/dist/esm/ui/ConfigPanel/Header.js +140 -0
- package/dist/esm/ui/ConfigPanel/LoadingState.js +17 -0
- package/dist/esm/ui/ConfigPanel/NestedForms/RemovableField.js +53 -0
- package/dist/esm/ui/ConfigPanel/constants.js +7 -0
- package/dist/esm/ui/ConfigPanel/index.js +2 -0
- package/dist/esm/ui/ConfigPanel/messages.js +93 -0
- package/dist/esm/ui/ConfigPanel/transformers.js +624 -0
- package/dist/esm/ui/ConfigPanel/types.js +9 -0
- package/dist/esm/ui/ConfigPanel/use-abortable-effect/index.js +49 -0
- package/dist/esm/ui/ConfigPanel/use-state-from-promise/index.js +34 -0
- package/dist/esm/ui/ConfigPanel/utils.js +109 -0
- package/dist/esm/ui/SaveIndicator/SaveIndicator.js +72 -0
- package/dist/esm/ui/SaveIndicator/messages.js +8 -0
- package/dist/esm/ui/SaveIndicator/types.js +1 -0
- package/dist/esm/utils.js +67 -0
- package/dist/types/actions.d.ts +20 -0
- package/dist/types/commands.d.ts +15 -0
- package/dist/types/context-panel.d.ts +10 -0
- package/dist/types/extension-api.d.ts +12 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/plugin-factory.d.ts +4 -0
- package/dist/types/plugin-key.d.ts +3 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -0
- package/dist/types/pm-plugins/macro/actions.d.ts +9 -0
- package/dist/types/pm-plugins/macro/index.d.ts +8 -0
- package/dist/types/pm-plugins/macro/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types/pm-plugins/main.d.ts +25 -0
- package/dist/types/pm-plugins/unique-id.d.ts +3 -0
- package/dist/types/pm-plugins/utils.d.ts +3 -0
- package/dist/types/reducer.d.ts +2 -0
- package/dist/types/toolbar.d.ts +44 -0
- package/dist/types/types.d.ts +27 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +22 -0
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +21 -0
- package/dist/types/ui/ConfigPanel/ConfigPanelLoader.d.ts +5 -0
- package/dist/types/ui/ConfigPanel/ErrorMessage/ErrorImage.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/ErrorMessage/index.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/FieldMessages.d.ts +12 -0
- package/dist/types/ui/ConfigPanel/Fields/Boolean.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/CheckboxGroup.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/ColorPicker.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/CustomSelect.d.ts +24 -0
- package/dist/types/ui/ConfigPanel/Fields/Date.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/DateRange.d.ts +20 -0
- package/dist/types/ui/ConfigPanel/Fields/Enum.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/Expand.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/Fields/Fieldset.d.ts +19 -0
- package/dist/types/ui/ConfigPanel/Fields/Number.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/RadioGroup.d.ts +8 -0
- package/dist/types/ui/ConfigPanel/Fields/Select.d.ts +11 -0
- package/dist/types/ui/ConfigPanel/Fields/SelectItem.d.ts +5 -0
- package/dist/types/ui/ConfigPanel/Fields/String.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/TabGroup.d.ts +14 -0
- package/dist/types/ui/ConfigPanel/Fields/UnhandledType.d.ts +6 -0
- package/dist/types/ui/ConfigPanel/Fields/UserSelect.d.ts +10 -0
- package/dist/types/ui/ConfigPanel/Fields/common/RequiredIndicator.d.ts +1 -0
- package/dist/types/ui/ConfigPanel/FormContent.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/Header.d.ts +23 -0
- package/dist/types/ui/ConfigPanel/LoadingState.d.ts +4 -0
- package/dist/types/ui/ConfigPanel/NestedForms/RemovableField.d.ts +19 -0
- package/dist/types/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/index.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/messages.d.ts +92 -0
- package/dist/types/ui/ConfigPanel/transformers.d.ts +9 -0
- package/dist/types/ui/ConfigPanel/types.d.ts +36 -0
- package/dist/types/ui/ConfigPanel/use-abortable-effect/index.d.ts +16 -0
- package/dist/types/ui/ConfigPanel/use-state-from-promise/index.d.ts +15 -0
- package/dist/types/ui/ConfigPanel/utils.d.ts +16 -0
- package/dist/types/ui/SaveIndicator/SaveIndicator.d.ts +4 -0
- package/dist/types/ui/SaveIndicator/messages.d.ts +7 -0
- package/dist/types/ui/SaveIndicator/types.d.ts +11 -0
- package/dist/types/utils.d.ts +15 -0
- package/dist/types-ts4.5/actions.d.ts +20 -0
- package/dist/types-ts4.5/commands.d.ts +15 -0
- package/dist/types-ts4.5/context-panel.d.ts +10 -0
- package/dist/types-ts4.5/extension-api.d.ts +12 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/plugin-factory.d.ts +4 -0
- package/dist/types-ts4.5/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/macro/actions.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/macro/index.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/macro/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/macro/types.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +25 -0
- package/dist/types-ts4.5/pm-plugins/unique-id.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +3 -0
- package/dist/types-ts4.5/reducer.d.ts +2 -0
- package/dist/types-ts4.5/toolbar.d.ts +44 -0
- package/dist/types-ts4.5/types.d.ts +27 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +22 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +21 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanelLoader.d.ts +5 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ErrorMessage/ErrorImage.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/ErrorMessage/index.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FieldMessages.d.ts +12 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Boolean.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/CheckboxGroup.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/ColorPicker.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/CustomSelect.d.ts +24 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Date.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/DateRange.d.ts +20 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Enum.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Expand.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Fieldset.d.ts +19 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Number.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/RadioGroup.d.ts +8 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/Select.d.ts +11 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/SelectItem.d.ts +5 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/String.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/TabGroup.d.ts +14 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/UnhandledType.d.ts +6 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/UserSelect.d.ts +10 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Fields/common/RequiredIndicator.d.ts +1 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FormContent.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/Header.d.ts +23 -0
- package/dist/types-ts4.5/ui/ConfigPanel/LoadingState.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfigPanel/NestedForms/RemovableField.d.ts +19 -0
- package/dist/types-ts4.5/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types-ts4.5/ui/ConfigPanel/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/ConfigPanel/messages.d.ts +92 -0
- package/dist/types-ts4.5/ui/ConfigPanel/transformers.d.ts +9 -0
- package/dist/types-ts4.5/ui/ConfigPanel/types.d.ts +39 -0
- package/dist/types-ts4.5/ui/ConfigPanel/use-abortable-effect/index.d.ts +16 -0
- package/dist/types-ts4.5/ui/ConfigPanel/use-state-from-promise/index.d.ts +18 -0
- package/dist/types-ts4.5/ui/ConfigPanel/utils.d.ts +16 -0
- package/dist/types-ts4.5/ui/SaveIndicator/SaveIndicator.d.ts +4 -0
- package/dist/types-ts4.5/ui/SaveIndicator/messages.d.ts +7 -0
- package/dist/types-ts4.5/ui/SaveIndicator/types.d.ts +11 -0
- package/dist/types-ts4.5/utils.d.ts +15 -0
- package/example-utils/config-panel/ConfigPanelWithExtensionPicker.tsx +217 -0
- package/example-utils/config-panel/ConfigPanelWithProviders.tsx +51 -0
- package/example-utils/config-panel/ExtensionNodePicker.tsx +141 -0
- package/example-utils/config-panel/FieldTypePicker.tsx +63 -0
- package/example-utils/config-panel/example-manifest-all-fields.ts +86 -0
- package/example-utils/config-panel/example-manifest-individual-fields.ts +85 -0
- package/example-utils/config-panel/fields.ts +611 -0
- package/package.json +49 -7
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
16
|
+
import _isEqual from 'lodash/isEqual';
|
|
17
|
+
import _mergeRecursive from 'lodash/merge';
|
|
18
|
+
import memoizeOne from 'memoize-one';
|
|
19
|
+
import { injectIntl } from 'react-intl-next';
|
|
20
|
+
import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
21
|
+
import ButtonGroup from '@atlaskit/button/button-group';
|
|
22
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
23
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
24
|
+
import { isTabGroup } from '@atlaskit/editor-common/extensions';
|
|
25
|
+
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
26
|
+
import Form, { FormFooter } from '@atlaskit/form';
|
|
27
|
+
import { pluginKey as extensionPluginKey } from '../../plugin-key';
|
|
28
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
|
|
29
|
+
import ErrorMessage from './ErrorMessage';
|
|
30
|
+
import FormContent from './FormContent';
|
|
31
|
+
import { FormErrorBoundary } from './FormErrorBoundary';
|
|
32
|
+
import Header from './Header';
|
|
33
|
+
import LoadingState from './LoadingState';
|
|
34
|
+
import { messages } from './messages';
|
|
35
|
+
import { deserialize, findDuplicateFields, serialize } from './transformers';
|
|
36
|
+
import { getLoggedParameters } from './utils';
|
|
37
|
+
function ConfigForm(_ref) {
|
|
38
|
+
var canSave = _ref.canSave,
|
|
39
|
+
errorMessage = _ref.errorMessage,
|
|
40
|
+
extensionManifest = _ref.extensionManifest,
|
|
41
|
+
fields = _ref.fields,
|
|
42
|
+
firstVisibleFieldName = _ref.firstVisibleFieldName,
|
|
43
|
+
hasParsedParameters = _ref.hasParsedParameters,
|
|
44
|
+
intl = _ref.intl,
|
|
45
|
+
isLoading = _ref.isLoading,
|
|
46
|
+
onCancel = _ref.onCancel,
|
|
47
|
+
onFieldChange = _ref.onFieldChange,
|
|
48
|
+
parameters = _ref.parameters,
|
|
49
|
+
submitting = _ref.submitting,
|
|
50
|
+
contextIdentifierProvider = _ref.contextIdentifierProvider,
|
|
51
|
+
featureFlags = _ref.featureFlags;
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
if (fields) {
|
|
54
|
+
var firstDuplicateField = findDuplicateFields(fields);
|
|
55
|
+
if (firstDuplicateField) {
|
|
56
|
+
throw new Error("Possible duplicate field name: `".concat(firstDuplicateField.name, "`."));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [fields]);
|
|
60
|
+
if (isLoading || !hasParsedParameters && errorMessage === null) {
|
|
61
|
+
return /*#__PURE__*/React.createElement(LoadingState, null);
|
|
62
|
+
}
|
|
63
|
+
if (errorMessage || !fields) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(ErrorMessage, {
|
|
65
|
+
errorMessage: errorMessage || ''
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormContent, {
|
|
69
|
+
fields: fields,
|
|
70
|
+
parameters: parameters,
|
|
71
|
+
extensionManifest: extensionManifest,
|
|
72
|
+
onFieldChange: onFieldChange,
|
|
73
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
74
|
+
contextIdentifierProvider: contextIdentifierProvider,
|
|
75
|
+
featureFlags: featureFlags
|
|
76
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
style: canSave ? {} : {
|
|
78
|
+
display: 'none'
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/React.createElement(FormFooter, {
|
|
81
|
+
align: "start"
|
|
82
|
+
}, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
|
|
83
|
+
type: "submit",
|
|
84
|
+
appearance: "primary"
|
|
85
|
+
}, intl.formatMessage(messages.submit)), /*#__PURE__*/React.createElement(Button, {
|
|
86
|
+
appearance: "default",
|
|
87
|
+
isDisabled: submitting,
|
|
88
|
+
onClick: onCancel
|
|
89
|
+
}, intl.formatMessage(messages.cancel))))));
|
|
90
|
+
}
|
|
91
|
+
var ConfigFormIntl = injectIntl(ConfigForm);
|
|
92
|
+
var WithOnFieldChange = function WithOnFieldChange(_ref2) {
|
|
93
|
+
var getState = _ref2.getState,
|
|
94
|
+
autoSave = _ref2.autoSave,
|
|
95
|
+
handleSubmit = _ref2.handleSubmit,
|
|
96
|
+
children = _ref2.children;
|
|
97
|
+
var getStateRef = useRef(getState);
|
|
98
|
+
useEffect(function () {
|
|
99
|
+
getStateRef.current = getState;
|
|
100
|
+
}, [getState]);
|
|
101
|
+
var handleFieldChange = useCallback(function (name, isDirty) {
|
|
102
|
+
if (!autoSave) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Don't trigger submit if nothing actually changed
|
|
107
|
+
if (!isDirty) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
var _getStateRef$current = getStateRef.current(),
|
|
111
|
+
errors = _getStateRef$current.errors,
|
|
112
|
+
values = _getStateRef$current.values;
|
|
113
|
+
|
|
114
|
+
// Get only values that does not contain errors
|
|
115
|
+
var validValues = {};
|
|
116
|
+
for (var _i = 0, _Object$keys = Object.keys(values); _i < _Object$keys.length; _i++) {
|
|
117
|
+
var key = _Object$keys[_i];
|
|
118
|
+
if (!errors[key]) {
|
|
119
|
+
// not has error
|
|
120
|
+
validValues[key] = values[key];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
handleSubmit(validValues);
|
|
124
|
+
}, [autoSave, handleSubmit]);
|
|
125
|
+
return children(handleFieldChange);
|
|
126
|
+
};
|
|
127
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
128
|
+
var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
129
|
+
_inherits(ConfigPanel, _React$Component);
|
|
130
|
+
var _super = _createSuper(ConfigPanel);
|
|
131
|
+
function ConfigPanel(props) {
|
|
132
|
+
var _this;
|
|
133
|
+
_classCallCheck(this, ConfigPanel);
|
|
134
|
+
_this = _super.call(this, props);
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (e) {
|
|
136
|
+
if ((e.key === 'Esc' || e.key === 'Escape') && _this.props.closeOnEsc) {
|
|
137
|
+
_this.props.onCancel();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
// https://product-fabric.atlassian.net/browse/DST-2697
|
|
141
|
+
// workaround for DST-2697, remove this function once fix.
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "backfillTabFormData", function (fields, formData, currentParameters) {
|
|
143
|
+
var getRelevantData = function getRelevantData(field, formParams, currentParams, backfill) {
|
|
144
|
+
if (field.hasGroupedValues && !(field.name in backfill)) {
|
|
145
|
+
backfill[field.name] = {};
|
|
146
|
+
}
|
|
147
|
+
var actualFormParams = field.hasGroupedValues ? formParams[field.name] || {} : formParams;
|
|
148
|
+
var actualCurrentParams = field.hasGroupedValues ? currentParams[field.name] || {} : currentParams;
|
|
149
|
+
var actualBackfillParams = field.hasGroupedValues ? backfill[field.name] : backfill;
|
|
150
|
+
return {
|
|
151
|
+
formParams: actualFormParams,
|
|
152
|
+
currentParams: actualCurrentParams,
|
|
153
|
+
backfillParams: actualBackfillParams
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Traverse any tab structures and backfill field values on tabs
|
|
158
|
+
// which aren't shown. This filter should be ok because tabs are
|
|
159
|
+
// currently only allowed on top level
|
|
160
|
+
var mergedTabGroups = fields.filter(isTabGroup).reduce(function (missingBackfill, tabGroup) {
|
|
161
|
+
var _getRelevantData = getRelevantData(tabGroup, formData, currentParameters, missingBackfill),
|
|
162
|
+
tabGroupFormData = _getRelevantData.formParams,
|
|
163
|
+
tabGroupCurrentData = _getRelevantData.currentParams,
|
|
164
|
+
tabGroupParams = _getRelevantData.backfillParams;
|
|
165
|
+
|
|
166
|
+
// Loop through tabs and see what fields are missing from current data
|
|
167
|
+
tabGroup.fields.forEach(function (tabField) {
|
|
168
|
+
var _getRelevantData2 = getRelevantData(tabField, tabGroupFormData, tabGroupCurrentData, tabGroupParams),
|
|
169
|
+
tabFormData = _getRelevantData2.formParams,
|
|
170
|
+
tabCurrentData = _getRelevantData2.currentParams,
|
|
171
|
+
tabParams = _getRelevantData2.backfillParams;
|
|
172
|
+
tabField.fields.forEach(function (field) {
|
|
173
|
+
if (field.name in tabFormData || !(field.name in tabCurrentData)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
tabParams[field.name] = tabCurrentData[field.name];
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
return missingBackfill;
|
|
180
|
+
}, {});
|
|
181
|
+
return _mergeRecursive({}, mergedTabGroups, formData);
|
|
182
|
+
});
|
|
183
|
+
_defineProperty(_assertThisInitialized(_this), "handleSubmit", /*#__PURE__*/function () {
|
|
184
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formData) {
|
|
185
|
+
var _this$props, fields, extensionManifest, onChange, autoSaveReject, serializedData;
|
|
186
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
187
|
+
while (1) switch (_context.prev = _context.next) {
|
|
188
|
+
case 0:
|
|
189
|
+
_this$props = _this.props, fields = _this$props.fields, extensionManifest = _this$props.extensionManifest, onChange = _this$props.onChange, autoSaveReject = _this$props.autoSaveReject;
|
|
190
|
+
if (!(!extensionManifest || !fields)) {
|
|
191
|
+
_context.next = 4;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (!extensionManifest) {
|
|
195
|
+
autoSaveReject === null || autoSaveReject === void 0 || autoSaveReject(new Error('Extension manifest not loaded'));
|
|
196
|
+
} else if (!fields) {
|
|
197
|
+
autoSaveReject === null || autoSaveReject === void 0 || autoSaveReject(new Error('Config fields not loaded'));
|
|
198
|
+
}
|
|
199
|
+
return _context.abrupt("return");
|
|
200
|
+
case 4:
|
|
201
|
+
_context.prev = 4;
|
|
202
|
+
_context.next = 7;
|
|
203
|
+
return serialize(extensionManifest, _this.backfillTabFormData(fields, formData, _this.state.currentParameters), fields);
|
|
204
|
+
case 7:
|
|
205
|
+
serializedData = _context.sent;
|
|
206
|
+
onChange(serializedData);
|
|
207
|
+
_context.next = 15;
|
|
208
|
+
break;
|
|
209
|
+
case 11:
|
|
210
|
+
_context.prev = 11;
|
|
211
|
+
_context.t0 = _context["catch"](4);
|
|
212
|
+
autoSaveReject === null || autoSaveReject === void 0 || autoSaveReject(_context.t0);
|
|
213
|
+
// eslint-disable-next-line no-console
|
|
214
|
+
console.error("Error serializing parameters", _context.t0);
|
|
215
|
+
case 15:
|
|
216
|
+
case "end":
|
|
217
|
+
return _context.stop();
|
|
218
|
+
}
|
|
219
|
+
}, _callee, null, [[4, 11]]);
|
|
220
|
+
}));
|
|
221
|
+
return function (_x) {
|
|
222
|
+
return _ref3.apply(this, arguments);
|
|
223
|
+
};
|
|
224
|
+
}());
|
|
225
|
+
_defineProperty(_assertThisInitialized(_this), "parseParameters", /*#__PURE__*/function () {
|
|
226
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fields, parameters) {
|
|
227
|
+
var extensionManifest, currentParameters;
|
|
228
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
229
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
230
|
+
case 0:
|
|
231
|
+
extensionManifest = _this.props.extensionManifest;
|
|
232
|
+
if (!(!extensionManifest || !fields || fields.length === 0)) {
|
|
233
|
+
_context2.next = 3;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
return _context2.abrupt("return");
|
|
237
|
+
case 3:
|
|
238
|
+
if (!(typeof parameters === 'undefined')) {
|
|
239
|
+
_context2.next = 6;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
_this.setState({
|
|
243
|
+
currentParameters: {},
|
|
244
|
+
hasParsedParameters: true
|
|
245
|
+
});
|
|
246
|
+
return _context2.abrupt("return");
|
|
247
|
+
case 6:
|
|
248
|
+
_context2.next = 8;
|
|
249
|
+
return deserialize(extensionManifest, parameters, fields);
|
|
250
|
+
case 8:
|
|
251
|
+
currentParameters = _context2.sent;
|
|
252
|
+
_this.setState({
|
|
253
|
+
currentParameters: currentParameters,
|
|
254
|
+
hasParsedParameters: true
|
|
255
|
+
});
|
|
256
|
+
case 10:
|
|
257
|
+
case "end":
|
|
258
|
+
return _context2.stop();
|
|
259
|
+
}
|
|
260
|
+
}, _callee2);
|
|
261
|
+
}));
|
|
262
|
+
return function (_x2, _x3) {
|
|
263
|
+
return _ref4.apply(this, arguments);
|
|
264
|
+
};
|
|
265
|
+
}());
|
|
266
|
+
// memoized to prevent rerender on new parameters
|
|
267
|
+
_defineProperty(_assertThisInitialized(_this), "renderHeader", memoizeOne(function (extensionManifest) {
|
|
268
|
+
var _this$props2 = _this.props,
|
|
269
|
+
onCancel = _this$props2.onCancel,
|
|
270
|
+
showHeader = _this$props2.showHeader;
|
|
271
|
+
|
|
272
|
+
// Use a temporary allowlist of top 3 macros to test out a new "Documentation" CTA ("Need help?")
|
|
273
|
+
// This will be removed when Top 5 Modernized Macros updates are rolled out
|
|
274
|
+
var modernizedMacrosList = ['children', 'recently-updated', 'excerpt'];
|
|
275
|
+
var enableHelpCTA = modernizedMacrosList.includes(extensionManifest.key);
|
|
276
|
+
if (!showHeader) {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
return /*#__PURE__*/React.createElement(Header, {
|
|
280
|
+
icon: extensionManifest.icons['48'],
|
|
281
|
+
title: extensionManifest.title,
|
|
282
|
+
description: extensionManifest.description,
|
|
283
|
+
summary: extensionManifest.summary,
|
|
284
|
+
documentationUrl: extensionManifest.documentationUrl,
|
|
285
|
+
onClose: onCancel,
|
|
286
|
+
enableHelpCTA: enableHelpCTA
|
|
287
|
+
});
|
|
288
|
+
}));
|
|
289
|
+
_defineProperty(_assertThisInitialized(_this), "getFirstVisibleFieldName", memoizeOne(function (fields) {
|
|
290
|
+
function nonHidden(field) {
|
|
291
|
+
if ('isHidden' in field) {
|
|
292
|
+
return !field.isHidden;
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// finds the first visible field, true for FieldSets too
|
|
298
|
+
var firstVisibleField = fields.find(nonHidden);
|
|
299
|
+
var newFirstVisibleFieldName;
|
|
300
|
+
if (firstVisibleField) {
|
|
301
|
+
// if it was a fieldset, go deeper trying to locate the field
|
|
302
|
+
if (firstVisibleField.type === 'fieldset') {
|
|
303
|
+
var firstVisibleFieldWithinFieldset = firstVisibleField.fields.find(nonHidden);
|
|
304
|
+
newFirstVisibleFieldName = firstVisibleFieldWithinFieldset && firstVisibleFieldWithinFieldset.name;
|
|
305
|
+
} else {
|
|
306
|
+
newFirstVisibleFieldName = firstVisibleField.name;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return newFirstVisibleFieldName;
|
|
310
|
+
}));
|
|
311
|
+
_defineProperty(_assertThisInitialized(_this), "setFirstVisibleFieldName", function (fields) {
|
|
312
|
+
var newFirstVisibleFieldName = _this.getFirstVisibleFieldName(fields);
|
|
313
|
+
if (newFirstVisibleFieldName !== _this.state.firstVisibleFieldName) {
|
|
314
|
+
_this.setState({
|
|
315
|
+
firstVisibleFieldName: newFirstVisibleFieldName
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
_this.state = {
|
|
320
|
+
hasParsedParameters: false,
|
|
321
|
+
currentParameters: {},
|
|
322
|
+
firstVisibleFieldName: props.fields ? _this.getFirstVisibleFieldName(props.fields) : undefined
|
|
323
|
+
};
|
|
324
|
+
_this.onFieldChange = null;
|
|
325
|
+
return _this;
|
|
326
|
+
}
|
|
327
|
+
_createClass(ConfigPanel, [{
|
|
328
|
+
key: "componentDidMount",
|
|
329
|
+
value: function componentDidMount() {
|
|
330
|
+
var _this$props3 = this.props,
|
|
331
|
+
fields = _this$props3.fields,
|
|
332
|
+
parameters = _this$props3.parameters;
|
|
333
|
+
this.parseParameters(fields, parameters);
|
|
334
|
+
}
|
|
335
|
+
}, {
|
|
336
|
+
key: "componentWillUnmount",
|
|
337
|
+
value: function componentWillUnmount() {
|
|
338
|
+
var _this$props4 = this.props,
|
|
339
|
+
createAnalyticsEvent = _this$props4.createAnalyticsEvent,
|
|
340
|
+
extensionManifest = _this$props4.extensionManifest,
|
|
341
|
+
fields = _this$props4.fields;
|
|
342
|
+
var currentParameters = this.state.currentParameters;
|
|
343
|
+
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
344
|
+
payload: {
|
|
345
|
+
action: ACTION.CLOSED,
|
|
346
|
+
actionSubject: ACTION_SUBJECT.CONFIG_PANEL,
|
|
347
|
+
eventType: EVENT_TYPE.UI,
|
|
348
|
+
attributes: _objectSpread({
|
|
349
|
+
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
350
|
+
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
351
|
+
}, extensionManifest !== null && extensionManifest !== void 0 && extensionManifest.key && ALLOWED_LOGGED_MACRO_PARAMS[extensionManifest.key] ? {
|
|
352
|
+
parameters: getLoggedParameters(extensionManifest.key, currentParameters, fields)
|
|
353
|
+
} : {})
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}, {
|
|
358
|
+
key: "componentDidUpdate",
|
|
359
|
+
value: function componentDidUpdate(prevProps) {
|
|
360
|
+
var _this$props5 = this.props,
|
|
361
|
+
parameters = _this$props5.parameters,
|
|
362
|
+
fields = _this$props5.fields,
|
|
363
|
+
autoSaveTrigger = _this$props5.autoSaveTrigger,
|
|
364
|
+
extensionManifest = _this$props5.extensionManifest;
|
|
365
|
+
if (parameters && parameters !== prevProps.parameters || fields && (!prevProps.fields || !_isEqual(fields, prevProps.fields))) {
|
|
366
|
+
this.parseParameters(fields, parameters);
|
|
367
|
+
}
|
|
368
|
+
if (fields && (!prevProps.fields || !_isEqual(fields, prevProps.fields))) {
|
|
369
|
+
this.setFirstVisibleFieldName(fields);
|
|
370
|
+
}
|
|
371
|
+
if (prevProps.autoSaveTrigger !== autoSaveTrigger) {
|
|
372
|
+
if (this.onFieldChange) {
|
|
373
|
+
this.onFieldChange('', true);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (prevProps.extensionManifest === undefined && prevProps.extensionManifest !== extensionManifest) {
|
|
377
|
+
// This will only be fired once when extensionManifest is loaded initially
|
|
378
|
+
// Can't do this in componentDidMount because extensionManifest is still undefined at that point
|
|
379
|
+
fireAnalyticsEvent(this.props.createAnalyticsEvent)({
|
|
380
|
+
payload: {
|
|
381
|
+
action: ACTION.OPENED,
|
|
382
|
+
actionSubject: ACTION_SUBJECT.CONFIG_PANEL,
|
|
383
|
+
eventType: EVENT_TYPE.UI,
|
|
384
|
+
attributes: {
|
|
385
|
+
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
386
|
+
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "render",
|
|
394
|
+
value: function render() {
|
|
395
|
+
var _this2 = this;
|
|
396
|
+
var _this$props6 = this.props,
|
|
397
|
+
extensionManifest = _this$props6.extensionManifest,
|
|
398
|
+
featureFlags = _this$props6.featureFlags;
|
|
399
|
+
if (!extensionManifest) {
|
|
400
|
+
return /*#__PURE__*/React.createElement(LoadingState, null);
|
|
401
|
+
}
|
|
402
|
+
var _this$props7 = this.props,
|
|
403
|
+
autoSave = _this$props7.autoSave,
|
|
404
|
+
errorMessage = _this$props7.errorMessage,
|
|
405
|
+
fields = _this$props7.fields,
|
|
406
|
+
isLoading = _this$props7.isLoading,
|
|
407
|
+
onCancel = _this$props7.onCancel;
|
|
408
|
+
var _this$state = this.state,
|
|
409
|
+
currentParameters = _this$state.currentParameters,
|
|
410
|
+
hasParsedParameters = _this$state.hasParsedParameters,
|
|
411
|
+
firstVisibleFieldName = _this$state.firstVisibleFieldName;
|
|
412
|
+
var handleSubmit = this.handleSubmit,
|
|
413
|
+
handleKeyDown = this.handleKeyDown;
|
|
414
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
415
|
+
onSubmit: handleSubmit
|
|
416
|
+
}, function (_ref5) {
|
|
417
|
+
var formProps = _ref5.formProps,
|
|
418
|
+
getState = _ref5.getState,
|
|
419
|
+
submitting = _ref5.submitting;
|
|
420
|
+
return /*#__PURE__*/React.createElement(WithOnFieldChange, {
|
|
421
|
+
autoSave: !!autoSave,
|
|
422
|
+
getState: getState,
|
|
423
|
+
handleSubmit: handleSubmit
|
|
424
|
+
}, function (onFieldChange) {
|
|
425
|
+
_this2.onFieldChange = onFieldChange;
|
|
426
|
+
return /*#__PURE__*/React.createElement("form", _extends({}, formProps, {
|
|
427
|
+
noValidate: true,
|
|
428
|
+
onKeyDown: handleKeyDown,
|
|
429
|
+
"data-testid": "extension-config-panel"
|
|
430
|
+
}), _this2.renderHeader(extensionManifest), /*#__PURE__*/React.createElement(WithPluginState, {
|
|
431
|
+
plugins: {
|
|
432
|
+
extension: extensionPluginKey
|
|
433
|
+
},
|
|
434
|
+
render: function render(_ref6) {
|
|
435
|
+
var extension = _ref6.extension;
|
|
436
|
+
return /*#__PURE__*/React.createElement(FormErrorBoundary, {
|
|
437
|
+
contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
|
|
438
|
+
extensionKey: extensionManifest.key,
|
|
439
|
+
fields: fields || []
|
|
440
|
+
}, /*#__PURE__*/React.createElement(ConfigFormIntl, {
|
|
441
|
+
canSave: !autoSave,
|
|
442
|
+
errorMessage: errorMessage,
|
|
443
|
+
extensionManifest: extensionManifest,
|
|
444
|
+
fields: fields,
|
|
445
|
+
firstVisibleFieldName: firstVisibleFieldName,
|
|
446
|
+
hasParsedParameters: hasParsedParameters,
|
|
447
|
+
isLoading: isLoading || false,
|
|
448
|
+
onCancel: onCancel,
|
|
449
|
+
onFieldChange: onFieldChange,
|
|
450
|
+
parameters: currentParameters,
|
|
451
|
+
submitting: submitting,
|
|
452
|
+
contextIdentifierProvider: extension === null || extension === void 0 ? void 0 : extension.contextIdentifierProvider,
|
|
453
|
+
featureFlags: featureFlags
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
456
|
+
}));
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}]);
|
|
461
|
+
return ConfigPanel;
|
|
462
|
+
}(React.Component);
|
|
463
|
+
export default withAnalyticsContext({
|
|
464
|
+
source: 'ConfigPanel'
|
|
465
|
+
})(withAnalyticsEvents()(ConfigPanel));
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import ConfigPanel from './ConfigPanel';
|
|
4
|
+
import { useStateFromPromise } from './use-state-from-promise';
|
|
5
|
+
var getFieldsDefinitionFn = function getFieldsDefinitionFn(extensionManifest, nodeKey) {
|
|
6
|
+
if (extensionManifest && extensionManifest.modules.nodes && extensionManifest.modules.nodes[nodeKey] && extensionManifest.modules.nodes[nodeKey].getFieldsDefinition) {
|
|
7
|
+
return extensionManifest.modules.nodes[nodeKey].getFieldsDefinition;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// having the default value in the props instead of a reference will cause excessive rerenders
|
|
12
|
+
var defaultEmptyObject = {};
|
|
13
|
+
var FieldDefinitionsPromiseResolver = function FieldDefinitionsPromiseResolver(props) {
|
|
14
|
+
var extensionManifest = props.extensionManifest,
|
|
15
|
+
nodeKey = props.nodeKey,
|
|
16
|
+
extensionParameters = props.extensionParameters,
|
|
17
|
+
setErrorMessage = props.setErrorMessage;
|
|
18
|
+
var _useState = useState(undefined),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
fields = _useState2[0],
|
|
21
|
+
setFields = _useState2[1];
|
|
22
|
+
|
|
23
|
+
// Resolve the promise
|
|
24
|
+
// useStateFromPromise() has an issue which isn't compatible with
|
|
25
|
+
// DynamicFieldDefinitions when it returns a function as setState()
|
|
26
|
+
// will immediately run the function returned and pass it the currentState.
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
if (!extensionManifest) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
var promiseFn = getFieldsDefinitionFn(extensionManifest, nodeKey);
|
|
32
|
+
if (typeof promiseFn !== 'function') {
|
|
33
|
+
setFields(undefined);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
promiseFn(extensionParameters).catch(function (err) {
|
|
37
|
+
if (err && typeof err.message === 'string') {
|
|
38
|
+
setErrorMessage(err.message);
|
|
39
|
+
}
|
|
40
|
+
setFields(undefined);
|
|
41
|
+
}).then(function (value) {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
// value: FieldDefinition[]
|
|
44
|
+
setFields(value);
|
|
45
|
+
} else if (typeof value === 'function') {
|
|
46
|
+
try {
|
|
47
|
+
// value: DynamicFieldDefinitions
|
|
48
|
+
var dynamicFields = value(extensionParameters);
|
|
49
|
+
setFields(dynamicFields);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (err instanceof Error) {
|
|
52
|
+
setErrorMessage(err.message);
|
|
53
|
+
}
|
|
54
|
+
setFields(undefined);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
// value: undefined
|
|
58
|
+
setFields(undefined);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}, [extensionManifest, nodeKey, extensionParameters, setErrorMessage]);
|
|
62
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children(fields));
|
|
63
|
+
};
|
|
64
|
+
export default function FieldsLoader(_ref) {
|
|
65
|
+
var extensionType = _ref.extensionType,
|
|
66
|
+
extensionKey = _ref.extensionKey,
|
|
67
|
+
nodeKey = _ref.nodeKey,
|
|
68
|
+
extensionProvider = _ref.extensionProvider,
|
|
69
|
+
_ref$extensionParamet = _ref.extensionParameters,
|
|
70
|
+
extensionParameters = _ref$extensionParamet === void 0 ? defaultEmptyObject : _ref$extensionParamet,
|
|
71
|
+
_ref$parameters = _ref.parameters,
|
|
72
|
+
parameters = _ref$parameters === void 0 ? defaultEmptyObject : _ref$parameters,
|
|
73
|
+
autoSave = _ref.autoSave,
|
|
74
|
+
autoSaveTrigger = _ref.autoSaveTrigger,
|
|
75
|
+
autoSaveReject = _ref.autoSaveReject,
|
|
76
|
+
closeOnEsc = _ref.closeOnEsc,
|
|
77
|
+
showHeader = _ref.showHeader,
|
|
78
|
+
featureFlags = _ref.featureFlags,
|
|
79
|
+
onChange = _ref.onChange,
|
|
80
|
+
onCancel = _ref.onCancel;
|
|
81
|
+
var _useStateFromPromise = useStateFromPromise(function () {
|
|
82
|
+
return extensionProvider.getExtension(extensionType, extensionKey);
|
|
83
|
+
}, [extensionProvider, extensionType, extensionKey]),
|
|
84
|
+
_useStateFromPromise2 = _slicedToArray(_useStateFromPromise, 1),
|
|
85
|
+
extensionManifest = _useStateFromPromise2[0];
|
|
86
|
+
var _useState3 = useState(null),
|
|
87
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
88
|
+
errorMessage = _useState4[0],
|
|
89
|
+
setErrorMessage = _useState4[1];
|
|
90
|
+
return /*#__PURE__*/React.createElement(FieldDefinitionsPromiseResolver, {
|
|
91
|
+
setErrorMessage: setErrorMessage,
|
|
92
|
+
extensionManifest: extensionManifest,
|
|
93
|
+
nodeKey: nodeKey,
|
|
94
|
+
extensionParameters: extensionParameters
|
|
95
|
+
}, function (fields) {
|
|
96
|
+
return /*#__PURE__*/React.createElement(ConfigPanel, {
|
|
97
|
+
extensionManifest: extensionManifest,
|
|
98
|
+
isLoading: !extensionManifest || errorMessage === null && !fields,
|
|
99
|
+
fields: fields,
|
|
100
|
+
parameters: parameters,
|
|
101
|
+
autoSave: autoSave,
|
|
102
|
+
autoSaveTrigger: autoSaveTrigger,
|
|
103
|
+
autoSaveReject: autoSaveReject,
|
|
104
|
+
closeOnEsc: closeOnEsc,
|
|
105
|
+
showHeader: showHeader,
|
|
106
|
+
onChange: onChange,
|
|
107
|
+
onCancel: onCancel,
|
|
108
|
+
errorMessage: errorMessage,
|
|
109
|
+
featureFlags: featureFlags
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Loadable from 'react-loadable';
|
|
2
|
+
import LoadingState from './LoadingState';
|
|
3
|
+
export default Loadable({
|
|
4
|
+
loader: function loader() {
|
|
5
|
+
return import( /* webpackChunkName: "@atlaskit-internal_editor-core-config-panel" */
|
|
6
|
+
'./ConfigPanelFieldsLoader').then(function (module) {
|
|
7
|
+
return module.default;
|
|
8
|
+
});
|
|
9
|
+
},
|
|
10
|
+
loading: LoadingState
|
|
11
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
|
+
// Quality Ticket: https://product-fabric.atlassian.net/browse/DSP-4249
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
var imageContainerStyles = css({
|
|
7
|
+
margin: "0 auto ".concat("var(--ds-space-300, 24px)"),
|
|
8
|
+
height: '80px'
|
|
9
|
+
});
|
|
10
|
+
var ErrorImage = function ErrorImage() {
|
|
11
|
+
return jsx("div", {
|
|
12
|
+
css: imageContainerStyles
|
|
13
|
+
}, jsx("svg", {
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
viewBox: "0 0 163.28 218",
|
|
16
|
+
height: "80"
|
|
17
|
+
}, jsx("defs", null, jsx("linearGradient", {
|
|
18
|
+
id: "linear-gradient",
|
|
19
|
+
x1: "133.86",
|
|
20
|
+
x2: "-2.79",
|
|
21
|
+
y1: "136.43",
|
|
22
|
+
y2: "200.15",
|
|
23
|
+
gradientUnits: "userSpaceOnUse"
|
|
24
|
+
}, jsx("stop", {
|
|
25
|
+
offset: "0",
|
|
26
|
+
stopColor: "#ffd740"
|
|
27
|
+
}), jsx("stop", {
|
|
28
|
+
offset: "1",
|
|
29
|
+
stopColor: "#ffab00"
|
|
30
|
+
})), jsx("clipPath", {
|
|
31
|
+
id: "clip-path"
|
|
32
|
+
}, jsx("path", {
|
|
33
|
+
id: "_Polygon_",
|
|
34
|
+
d: "M94.78 80.16l66.44 115.08A15.17 15.17 0 01148.08 218H15.2a15.17 15.17 0 01-13.14-22.76L68.5 80.16a15.17 15.17 0 0126.28 0z",
|
|
35
|
+
className: "cls-1",
|
|
36
|
+
"data-name": "<Polygon>"
|
|
37
|
+
})), jsx("style", null, ".cls-1{fill:url(#linear-gradient)}.cls-2{fill:#253858}.cls-6{fill:none;stroke-linecap:round;stroke-miterlimit:10;stroke-width:2px;stroke:#5e6c84}")), jsx("g", {
|
|
38
|
+
id: "Layer_2",
|
|
39
|
+
"data-name": "Layer 2"
|
|
40
|
+
}, jsx("g", {
|
|
41
|
+
id: "Software"
|
|
42
|
+
}, jsx("path", {
|
|
43
|
+
id: "_Polygon_2",
|
|
44
|
+
d: "M94.78 80.16l66.44 115.08A15.17 15.17 0 01148.08 218H15.2a15.17 15.17 0 01-13.14-22.76L68.5 80.16a15.17 15.17 0 0126.28 0z",
|
|
45
|
+
className: "cls-1",
|
|
46
|
+
"data-name": "<Polygon>"
|
|
47
|
+
}), jsx("path", {
|
|
48
|
+
d: "M87.22 163.71l2.88-44.35a9.18 9.18 0 00-9.16-9.78 9.18 9.18 0 00-9.16 9.78l2.88 44.35a6.3 6.3 0 006.28 5.89 6.3 6.3 0 006.28-5.89zM71.38 187.25a9.53 9.53 0 0010.39 9.58 9.68 9.68 0 00-.9-19.32 9.64 9.64 0 00-9.49 9.74z",
|
|
49
|
+
className: "cls-2"
|
|
50
|
+
}), jsx("path", {
|
|
51
|
+
fill: "#ffc400",
|
|
52
|
+
d: "M91.7 27.17L84.29.45A.61.61 0 0083.1.5l-4.66 25.1-5.8-1.08a.61.61 0 00-.7.76L79.35 52a.61.61 0 001.19 0l4.66-25.1 5.8 1.03a.61.61 0 00.7-.76z"
|
|
53
|
+
}), jsx("path", {
|
|
54
|
+
fill: "#ffab00",
|
|
55
|
+
d: "M65.12 41.81l-10.88-8.55a.27.27 0 00-.41.33L59.36 45l-2.66 1.31a.27.27 0 000 .45l10.87 8.55a.27.27 0 00.41-.33l-5.57-11.43 2.66-1.29a.27.27 0 00.05-.45z"
|
|
56
|
+
}), jsx("path", {
|
|
57
|
+
fill: "none",
|
|
58
|
+
stroke: "#344563",
|
|
59
|
+
strokeLinecap: "round",
|
|
60
|
+
strokeMiterlimit: "10",
|
|
61
|
+
strokeWidth: "2",
|
|
62
|
+
d: "M115.15 36.6c-1.17 1.59-11-5.6-12.16-4s8.66 8.79 7.5 10.39-11-5.6-12.17-4 8.66 8.79 7.49 10.39-11-5.6-12.17-4 8.66 8.79 7.49 10.39"
|
|
63
|
+
}), jsx("path", {
|
|
64
|
+
d: "M119.92 64.19c-1.46 1.33-7.05-4.78-8.51-3.44s4.13 7.45 2.67 8.78-7.05-4.78-8.51-3.44c-.68.62.16 2.27 1.11 4M44.8 64c1.82.77 5-6.87 6.86-6.1s-1.39 8.4.43 9.17 5-6.87 6.86-6.1c.85.36.61 2.19.29 4.13",
|
|
65
|
+
className: "cls-6"
|
|
66
|
+
})))));
|
|
67
|
+
};
|
|
68
|
+
export default ErrorImage;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
3
|
+
import EmptyState from '@atlaskit/empty-state';
|
|
4
|
+
import ErrorImage from './ErrorImage';
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
configFailedToLoad: {
|
|
7
|
+
id: 'fabric.editor.configFailedToLoad',
|
|
8
|
+
defaultMessage: 'Failed to load',
|
|
9
|
+
description: 'Displayed when the config panel fails to load fields'
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var ConfigPanelErrorMessage = function ConfigPanelErrorMessage(_ref) {
|
|
13
|
+
var errorMessage = _ref.errorMessage,
|
|
14
|
+
intl = _ref.intl;
|
|
15
|
+
return /*#__PURE__*/React.createElement(EmptyState, {
|
|
16
|
+
header: intl.formatMessage(messages.configFailedToLoad),
|
|
17
|
+
description: errorMessage,
|
|
18
|
+
renderImage: function renderImage() {
|
|
19
|
+
return /*#__PURE__*/React.createElement(ErrorImage, null);
|
|
20
|
+
},
|
|
21
|
+
size: "narrow",
|
|
22
|
+
imageHeight: 80,
|
|
23
|
+
testId: "config-panel-error-message"
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export default injectIntl(ConfigPanelErrorMessage);
|