@atlaskit/editor-core 189.4.18 → 189.4.19

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 189.4.19
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58316](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58316) [`eb496c9a3474`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eb496c9a3474) - Bug fixes for configuraton panel boolean & enum fields
8
+ - [#58763](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58763) [`0fdbd64522bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0fdbd64522bf) - update ADF schema
9
+
3
10
  ## 189.4.18
4
11
 
5
12
  ### Patch Changes
@@ -29,6 +29,12 @@ function _validate(value, isRequired) {
29
29
  return _types.ValidationError.Required;
30
30
  }
31
31
  }
32
+ function parseBoolean(value) {
33
+ if (typeof value === 'boolean') {
34
+ return value;
35
+ }
36
+ return value === 'true';
37
+ }
32
38
  function handleOnChange(onChange, onFieldChange, event) {
33
39
  var _event$target;
34
40
  onChange((event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.checked) || false);
@@ -67,7 +73,7 @@ function Checkbox(_ref) {
67
73
  onChange: function onChange(event) {
68
74
  return handleOnChange(fieldProps.onChange, onFieldChange, event);
69
75
  },
70
- isChecked: isChecked
76
+ isChecked: parseBoolean(isChecked)
71
77
  })), /*#__PURE__*/_react.default.createElement(_FieldMessages.default, {
72
78
  error: error,
73
79
  description: description
@@ -110,7 +116,7 @@ function Toggle(_ref3) {
110
116
  onChange: function onChange(event) {
111
117
  return handleOnChange(fieldProps.onChange, onFieldChange, event);
112
118
  },
113
- isChecked: isChecked
119
+ isChecked: parseBoolean(isChecked)
114
120
  }))), /*#__PURE__*/_react.default.createElement(_FieldMessages.default, {
115
121
  error: error,
116
122
  description: description
@@ -45,9 +45,9 @@ function FieldComponent(_ref) {
45
45
  var parentedName = (0, _utils.getSafeParentedName)(name, parentName);
46
46
  var fieldDefaultValue = field.type === 'enum' ? field.defaultValue : undefined;
47
47
  if (name in parameters && !(0, _extensions.isFieldset)(field)) {
48
- field = _objectSpread(_objectSpread({}, field), {}, {
48
+ field = _objectSpread(_objectSpread({}, field), defaultValue != null ? {
49
49
  defaultValue: defaultValue
50
- });
50
+ } : {});
51
51
  }
52
52
  switch (field.type) {
53
53
  case 'string':
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.validateRequired = exports.validate = exports.isDuplicateField = exports.getSafeParentedName = exports.getOptionFromValue = exports.getNameFromDuplicateField = exports.getLoggedParameters = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _select = require("@atlaskit/select");
9
10
  var _types = require("./types");
10
11
  var _constants = require("./constants");
11
12
  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; }
@@ -19,6 +20,11 @@ var isEmptyString = function isEmptyString(value) {
19
20
  var isEmptyArray = function isEmptyArray(value) {
20
21
  return Array.isArray(value) && value.length === 0;
21
22
  };
23
+ var getUngroupedOptions = function getUngroupedOptions(groupedOptions) {
24
+ return groupedOptions.flatMap(function (option) {
25
+ return option.options;
26
+ });
27
+ };
22
28
  var validateRequired = exports.validateRequired = function validateRequired(_ref, value) {
23
29
  var isRequired = _ref.isRequired,
24
30
  isMultiple = _ref.isMultiple;
@@ -34,10 +40,20 @@ var getOptionFromValue = exports.getOptionFromValue = function getOptionFromValu
34
40
  return undefined;
35
41
  }
36
42
  if (Array.isArray(value)) {
43
+ if ((0, _select.isOptionsGrouped)(options)) {
44
+ return getUngroupedOptions(options).filter(function (option) {
45
+ return value.includes(option.value);
46
+ });
47
+ }
37
48
  return options.filter(function (option) {
38
49
  return value.includes(option.value);
39
50
  });
40
51
  }
52
+ if ((0, _select.isOptionsGrouped)(options)) {
53
+ return getUngroupedOptions(options).find(function (option) {
54
+ return value === option.value;
55
+ });
56
+ }
41
57
  return options.find(function (option) {
42
58
  return value === option.value;
43
59
  });
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "189.4.18";
8
+ var version = exports.version = "189.4.19";
@@ -20,6 +20,12 @@ function validate(value, isRequired) {
20
20
  return ValidationError.Required;
21
21
  }
22
22
  }
23
+ function parseBoolean(value) {
24
+ if (typeof value === 'boolean') {
25
+ return value;
26
+ }
27
+ return value === 'true';
28
+ }
23
29
  function handleOnChange(onChange, onFieldChange, event) {
24
30
  var _event$target;
25
31
  onChange((event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.checked) || false);
@@ -58,7 +64,7 @@ function Checkbox({
58
64
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(AKCheckbox, _extends({}, restFieldProps, {
59
65
  label: label,
60
66
  onChange: event => handleOnChange(fieldProps.onChange, onFieldChange, event),
61
- isChecked: isChecked
67
+ isChecked: parseBoolean(isChecked)
62
68
  })), /*#__PURE__*/React.createElement(FieldMessages, {
63
69
  error: error,
64
70
  description: description
@@ -101,7 +107,7 @@ function Toggle({
101
107
  "aria-hidden": "true"
102
108
  }, "*") : null), /*#__PURE__*/React.createElement(AKToggle, _extends({}, restFieldProps, {
103
109
  onChange: event => handleOnChange(fieldProps.onChange, onFieldChange, event),
104
- isChecked: isChecked
110
+ isChecked: parseBoolean(isChecked)
105
111
  }))), /*#__PURE__*/React.createElement(FieldMessages, {
106
112
  error: error,
107
113
  description: description
@@ -38,7 +38,9 @@ export function FieldComponent({
38
38
  if (name in parameters && !isFieldset(field)) {
39
39
  field = {
40
40
  ...field,
41
- defaultValue
41
+ ...(defaultValue != null ? {
42
+ defaultValue
43
+ } : {})
42
44
  };
43
45
  }
44
46
  switch (field.type) {
@@ -1,3 +1,4 @@
1
+ import { isOptionsGrouped } from '@atlaskit/select';
1
2
  import { ValidationError } from './types';
2
3
  import { ALLOWED_LOGGED_MACRO_PARAMS, ALLOWED_PARAM_TYPES } from './constants';
3
4
  export const validate = (field, value) => {
@@ -5,6 +6,9 @@ export const validate = (field, value) => {
5
6
  };
6
7
  const isEmptyString = value => typeof value === 'string' && value === '';
7
8
  const isEmptyArray = value => Array.isArray(value) && value.length === 0;
9
+ const getUngroupedOptions = groupedOptions => {
10
+ return groupedOptions.flatMap(option => option.options);
11
+ };
8
12
  export const validateRequired = ({
9
13
  isRequired,
10
14
  isMultiple
@@ -21,8 +25,14 @@ export const getOptionFromValue = (options, value) => {
21
25
  return undefined;
22
26
  }
23
27
  if (Array.isArray(value)) {
28
+ if (isOptionsGrouped(options)) {
29
+ return getUngroupedOptions(options).filter(option => value.includes(option.value));
30
+ }
24
31
  return options.filter(option => value.includes(option.value));
25
32
  }
33
+ if (isOptionsGrouped(options)) {
34
+ return getUngroupedOptions(options).find(option => value === option.value);
35
+ }
26
36
  return options.find(option => value === option.value);
27
37
  };
28
38
 
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "189.4.18";
2
+ export const version = "189.4.19";
@@ -19,6 +19,12 @@ function _validate(value, isRequired) {
19
19
  return ValidationError.Required;
20
20
  }
21
21
  }
22
+ function parseBoolean(value) {
23
+ if (typeof value === 'boolean') {
24
+ return value;
25
+ }
26
+ return value === 'true';
27
+ }
22
28
  function handleOnChange(onChange, onFieldChange, event) {
23
29
  var _event$target;
24
30
  onChange((event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.checked) || false);
@@ -57,7 +63,7 @@ function Checkbox(_ref) {
57
63
  onChange: function onChange(event) {
58
64
  return handleOnChange(fieldProps.onChange, onFieldChange, event);
59
65
  },
60
- isChecked: isChecked
66
+ isChecked: parseBoolean(isChecked)
61
67
  })), /*#__PURE__*/React.createElement(FieldMessages, {
62
68
  error: error,
63
69
  description: description
@@ -100,7 +106,7 @@ function Toggle(_ref3) {
100
106
  onChange: function onChange(event) {
101
107
  return handleOnChange(fieldProps.onChange, onFieldChange, event);
102
108
  },
103
- isChecked: isChecked
109
+ isChecked: parseBoolean(isChecked)
104
110
  }))), /*#__PURE__*/React.createElement(FieldMessages, {
105
111
  error: error,
106
112
  description: description
@@ -37,9 +37,9 @@ export function FieldComponent(_ref) {
37
37
  var parentedName = getSafeParentedName(name, parentName);
38
38
  var fieldDefaultValue = field.type === 'enum' ? field.defaultValue : undefined;
39
39
  if (name in parameters && !isFieldset(field)) {
40
- field = _objectSpread(_objectSpread({}, field), {}, {
40
+ field = _objectSpread(_objectSpread({}, field), defaultValue != null ? {
41
41
  defaultValue: defaultValue
42
- });
42
+ } : {});
43
43
  }
44
44
  switch (field.type) {
45
45
  case 'string':
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
+ import { isOptionsGrouped } from '@atlaskit/select';
4
5
  import { ValidationError } from './types';
5
6
  import { ALLOWED_LOGGED_MACRO_PARAMS, ALLOWED_PARAM_TYPES } from './constants';
6
7
  export var validate = function validate(field, value) {
@@ -12,6 +13,11 @@ var isEmptyString = function isEmptyString(value) {
12
13
  var isEmptyArray = function isEmptyArray(value) {
13
14
  return Array.isArray(value) && value.length === 0;
14
15
  };
16
+ var getUngroupedOptions = function getUngroupedOptions(groupedOptions) {
17
+ return groupedOptions.flatMap(function (option) {
18
+ return option.options;
19
+ });
20
+ };
15
21
  export var validateRequired = function validateRequired(_ref, value) {
16
22
  var isRequired = _ref.isRequired,
17
23
  isMultiple = _ref.isMultiple;
@@ -27,10 +33,20 @@ export var getOptionFromValue = function getOptionFromValue(options, value) {
27
33
  return undefined;
28
34
  }
29
35
  if (Array.isArray(value)) {
36
+ if (isOptionsGrouped(options)) {
37
+ return getUngroupedOptions(options).filter(function (option) {
38
+ return value.includes(option.value);
39
+ });
40
+ }
30
41
  return options.filter(function (option) {
31
42
  return value.includes(option.value);
32
43
  });
33
44
  }
45
+ if (isOptionsGrouped(options)) {
46
+ return getUngroupedOptions(options).find(function (option) {
47
+ return value === option.value;
48
+ });
49
+ }
34
50
  return options.find(function (option) {
35
51
  return value === option.value;
36
52
  });
@@ -1,2 +1,2 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "189.4.18";
2
+ export var version = "189.4.19";
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
- import { BooleanField } from '@atlaskit/editor-common/extensions';
3
- import { OnFieldChange } from '../types';
2
+ import type { BooleanField } from '@atlaskit/editor-common/extensions';
3
+ import type { OnFieldChange } from '../types';
4
4
  export default function Boolean({ name, field, onFieldChange, }: {
5
5
  name: string;
6
6
  field: BooleanField;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { FieldComponentProps, FormContentProps } from './types';
2
+ import type { FieldComponentProps, FormContentProps } from './types';
3
3
  export declare function FieldComponent({ field, parameters, parentName, extensionManifest, firstVisibleFieldName, onFieldChange, featureFlags, }: FieldComponentProps): JSX.Element;
4
4
  export default function FormContent({ fields, parentName, parameters, extensionManifest, canRemoveFields, onClickRemove, onFieldChange, firstVisibleFieldName, contextIdentifierProvider, featureFlags, }: FormContentProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ import type { GroupBase } from 'react-select';
1
2
  import type { Option, FieldDefinition, Parameters } from '@atlaskit/editor-common/extensions';
2
3
  import { ValidationError } from './types';
3
4
  export declare const validate: <T>(field: Partial<FieldDefinition>, value: T) => ValidationError | undefined;
@@ -6,7 +7,7 @@ type ValidationProps = {
6
7
  isMultiple?: boolean;
7
8
  };
8
9
  export declare const validateRequired: <T>({ isRequired, isMultiple }: ValidationProps, value: T) => ValidationError | undefined;
9
- export declare const getOptionFromValue: (options: Option[], value: string | string[] | undefined) => Option | Option[] | undefined;
10
+ export declare const getOptionFromValue: (options: Option[] | GroupBase<Option>[], value: string | string[] | undefined) => Option | Option[] | undefined;
10
11
  export declare const getSafeParentedName: (name: string, parentName?: string) => string;
11
12
  export declare const isDuplicateField: (key: string) => boolean;
12
13
  export declare const getNameFromDuplicateField: (key: string) => string;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from '@emotion/react';
2
- import { BooleanField } from '@atlaskit/editor-common/extensions';
3
- import { OnFieldChange } from '../types';
2
+ import type { BooleanField } from '@atlaskit/editor-common/extensions';
3
+ import type { OnFieldChange } from '../types';
4
4
  export default function Boolean({ name, field, onFieldChange, }: {
5
5
  name: string;
6
6
  field: BooleanField;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { FieldComponentProps, FormContentProps } from './types';
2
+ import type { FieldComponentProps, FormContentProps } from './types';
3
3
  export declare function FieldComponent({ field, parameters, parentName, extensionManifest, firstVisibleFieldName, onFieldChange, featureFlags, }: FieldComponentProps): JSX.Element;
4
4
  export default function FormContent({ fields, parentName, parameters, extensionManifest, canRemoveFields, onClickRemove, onFieldChange, firstVisibleFieldName, contextIdentifierProvider, featureFlags, }: FormContentProps): JSX.Element;
@@ -1,3 +1,4 @@
1
+ import type { GroupBase } from 'react-select';
1
2
  import type { Option, FieldDefinition, Parameters } from '@atlaskit/editor-common/extensions';
2
3
  import { ValidationError } from './types';
3
4
  export declare const validate: <T>(field: Partial<FieldDefinition>, value: T) => ValidationError | undefined;
@@ -6,7 +7,7 @@ type ValidationProps = {
6
7
  isMultiple?: boolean;
7
8
  };
8
9
  export declare const validateRequired: <T>({ isRequired, isMultiple }: ValidationProps, value: T) => ValidationError | undefined;
9
- export declare const getOptionFromValue: (options: Option[], value: string | string[] | undefined) => Option | Option[] | undefined;
10
+ export declare const getOptionFromValue: (options: Option[] | GroupBase<Option>[], value: string | string[] | undefined) => Option | Option[] | undefined;
10
11
  export declare const getSafeParentedName: (name: string, parentName?: string) => string;
11
12
  export declare const isDuplicateField: (key: string) => boolean;
12
13
  export declare const getNameFromDuplicateField: (key: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "189.4.18",
3
+ "version": "189.4.19",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@atlaskit/activity-provider": "^2.4.0",
43
- "@atlaskit/adf-schema": "^34.0.1",
43
+ "@atlaskit/adf-schema": "^35.0.0",
44
44
  "@atlaskit/adf-utils": "^19.0.0",
45
45
  "@atlaskit/analytics-namespaced-context": "^6.7.0",
46
46
  "@atlaskit/analytics-next": "^9.1.0",
@@ -170,7 +170,7 @@
170
170
  "@af/visual-regression": "*",
171
171
  "@atlaskit/analytics-listeners": "^8.7.0",
172
172
  "@atlaskit/code": "^15.1.0",
173
- "@atlaskit/collab-provider": "9.18.1",
173
+ "@atlaskit/collab-provider": "9.18.2",
174
174
  "@atlaskit/dropdown-menu": "^12.1.0",
175
175
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
176
176
  "@atlaskit/editor-palette": "1.5.2",