decap-cms-widget-list 3.2.3-beta.0 → 3.4.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 +7 -1
- package/dist/decap-cms-widget-list.js +4 -4
- package/dist/decap-cms-widget-list.js.LICENSE.txt +2 -12
- package/dist/decap-cms-widget-list.js.map +1 -1
- package/dist/esm/ListControl.js +516 -481
- package/dist/esm/index.js +12 -23
- package/dist/esm/schema.js +1 -7
- package/dist/esm/typedListHelpers.js +7 -17
- package/package.json +3 -3
- package/src/ListControl.js +91 -25
- package/src/__tests__/ListControl.spec.js +58 -58
- package/src/__tests__/__snapshots__/ListControl.spec.js.snap +97 -84
package/dist/esm/index.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.DecapCmsWidgetList = void 0;
|
|
7
|
-
var _decapCmsWidgetObject = _interopRequireDefault(require("decap-cms-widget-object"));
|
|
8
|
-
var _ListControl = _interopRequireDefault(require("./ListControl"));
|
|
9
|
-
var _schema = _interopRequireDefault(require("./schema"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
const previewComponent = _decapCmsWidgetObject.default.previewComponent;
|
|
1
|
+
import DecapCmsWidgetObject from 'decap-cms-widget-object';
|
|
2
|
+
import controlComponent from './ListControl';
|
|
3
|
+
import schema from './schema';
|
|
4
|
+
const previewComponent = DecapCmsWidgetObject.previewComponent;
|
|
17
5
|
function Widget(opts = {}) {
|
|
18
|
-
return
|
|
6
|
+
return {
|
|
19
7
|
name: 'list',
|
|
20
|
-
controlComponent
|
|
8
|
+
controlComponent,
|
|
21
9
|
previewComponent,
|
|
22
|
-
schema
|
|
23
|
-
|
|
10
|
+
schema,
|
|
11
|
+
...opts
|
|
12
|
+
};
|
|
24
13
|
}
|
|
25
|
-
const DecapCmsWidgetList =
|
|
14
|
+
export const DecapCmsWidgetList = {
|
|
26
15
|
Widget,
|
|
27
|
-
controlComponent
|
|
16
|
+
controlComponent,
|
|
28
17
|
previewComponent
|
|
29
18
|
};
|
|
30
|
-
|
|
19
|
+
export default DecapCmsWidgetList;
|
package/dist/esm/schema.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.TYPE_KEY = exports.TYPES_KEY = exports.DEFAULT_TYPE_KEY = void 0;
|
|
7
|
-
exports.getErrorMessageForTypedFieldAndValue = getErrorMessageForTypedFieldAndValue;
|
|
8
|
-
exports.getTypedFieldForValue = getTypedFieldForValue;
|
|
9
|
-
exports.resolveFieldKeyType = resolveFieldKeyType;
|
|
10
|
-
exports.resolveFunctionForTypedField = resolveFunctionForTypedField;
|
|
11
|
-
const TYPES_KEY = exports.TYPES_KEY = 'types';
|
|
12
|
-
const TYPE_KEY = exports.TYPE_KEY = 'typeKey';
|
|
13
|
-
const DEFAULT_TYPE_KEY = exports.DEFAULT_TYPE_KEY = 'type';
|
|
14
|
-
function getTypedFieldForValue(field, value) {
|
|
1
|
+
export const TYPES_KEY = 'types';
|
|
2
|
+
export const TYPE_KEY = 'typeKey';
|
|
3
|
+
export const DEFAULT_TYPE_KEY = 'type';
|
|
4
|
+
export function getTypedFieldForValue(field, value) {
|
|
15
5
|
const typeKey = resolveFieldKeyType(field);
|
|
16
6
|
const types = field.get(TYPES_KEY);
|
|
17
7
|
const valueType = value.get(typeKey);
|
|
18
8
|
return types.find(type => type.get('name') === valueType);
|
|
19
9
|
}
|
|
20
|
-
function resolveFunctionForTypedField(field) {
|
|
10
|
+
export function resolveFunctionForTypedField(field) {
|
|
21
11
|
const typeKey = resolveFieldKeyType(field);
|
|
22
12
|
const types = field.get(TYPES_KEY);
|
|
23
13
|
return value => {
|
|
@@ -25,10 +15,10 @@ function resolveFunctionForTypedField(field) {
|
|
|
25
15
|
return types.find(type => type.get('name') === valueType);
|
|
26
16
|
};
|
|
27
17
|
}
|
|
28
|
-
function resolveFieldKeyType(field) {
|
|
18
|
+
export function resolveFieldKeyType(field) {
|
|
29
19
|
return field.get(TYPE_KEY, DEFAULT_TYPE_KEY);
|
|
30
20
|
}
|
|
31
|
-
function getErrorMessageForTypedFieldAndValue(field, value) {
|
|
21
|
+
export function getErrorMessageForTypedFieldAndValue(field, value) {
|
|
32
22
|
const keyType = resolveFieldKeyType(field);
|
|
33
23
|
const type = value.get(keyType);
|
|
34
24
|
let errorMessage;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "decap-cms-widget-list",
|
|
3
3
|
"description": "Widget for editing lists in Decap CMS.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.4.0",
|
|
5
5
|
"homepage": "https://www.decapcms.org/docs/widgets/#list",
|
|
6
6
|
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-widget-list",
|
|
7
7
|
"bugs": "https://github.com/decaporg/decap-cms/issues",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"immutable": "^3.7.6",
|
|
35
35
|
"lodash": "^4.17.11",
|
|
36
36
|
"prop-types": "^15.7.2",
|
|
37
|
-
"react": "
|
|
37
|
+
"react": "^19.1.0",
|
|
38
38
|
"react-immutable-proptypes": "^2.1.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "ed7e99318007b83f4c57f3237bf92b931676820a"
|
|
41
41
|
}
|
package/src/ListControl.js
CHANGED
|
@@ -4,7 +4,9 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
5
|
import { css, ClassNames } from '@emotion/react';
|
|
6
6
|
import { List, Map, fromJS } from 'immutable';
|
|
7
|
-
import
|
|
7
|
+
import partial from 'lodash/partial';
|
|
8
|
+
import isEmpty from 'lodash/isEmpty';
|
|
9
|
+
import uniqueId from 'lodash/uniqueId';
|
|
8
10
|
import { v4 as uuid } from 'uuid';
|
|
9
11
|
import DecapCmsWidgetObject from 'decap-cms-widget-object';
|
|
10
12
|
import {
|
|
@@ -171,7 +173,7 @@ function LabelComponent({ field, isActive, hasErrors, uniqueFieldId, isFieldOpti
|
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
export default class ListControl extends React.Component {
|
|
174
|
-
|
|
176
|
+
childRefs = {};
|
|
175
177
|
|
|
176
178
|
static propTypes = {
|
|
177
179
|
metadata: ImmutablePropTypes.map,
|
|
@@ -219,6 +221,11 @@ export default class ListControl extends React.Component {
|
|
|
219
221
|
};
|
|
220
222
|
}
|
|
221
223
|
|
|
224
|
+
componentDidMount() {
|
|
225
|
+
// Manually validate PropTypes - React 19 breaking change
|
|
226
|
+
PropTypes.checkPropTypes(ListControl.propTypes, this.props, 'prop', 'ListControl');
|
|
227
|
+
}
|
|
228
|
+
|
|
222
229
|
valueToString = value => {
|
|
223
230
|
let stringValue;
|
|
224
231
|
if (List.isList(value) || Array.isArray(value)) {
|
|
@@ -365,16 +372,18 @@ export default class ListControl extends React.Component {
|
|
|
365
372
|
processControlRef = ref => {
|
|
366
373
|
if (!ref) return;
|
|
367
374
|
const {
|
|
368
|
-
validate,
|
|
369
375
|
props: { validationKey: key },
|
|
370
376
|
} = ref;
|
|
371
|
-
this.
|
|
377
|
+
this.childRefs[key] = ref;
|
|
378
|
+
this.props.controlRef?.(this);
|
|
372
379
|
};
|
|
373
380
|
|
|
374
381
|
validate = () => {
|
|
375
|
-
if
|
|
376
|
-
|
|
377
|
-
|
|
382
|
+
// First validate child widgets if this is a complex list
|
|
383
|
+
const hasChildWidgets = this.getValueType() && Object.keys(this.childRefs).length > 0;
|
|
384
|
+
if (hasChildWidgets) {
|
|
385
|
+
Object.values(this.childRefs).forEach(widget => {
|
|
386
|
+
widget?.validate?.();
|
|
378
387
|
});
|
|
379
388
|
} else {
|
|
380
389
|
this.props.validate();
|
|
@@ -431,7 +440,17 @@ export default class ListControl extends React.Component {
|
|
|
431
440
|
handleRemove = (index, event) => {
|
|
432
441
|
event.preventDefault();
|
|
433
442
|
const { itemsCollapsed } = this.state;
|
|
434
|
-
const {
|
|
443
|
+
const {
|
|
444
|
+
value,
|
|
445
|
+
metadata,
|
|
446
|
+
onChange,
|
|
447
|
+
field,
|
|
448
|
+
clearFieldErrors,
|
|
449
|
+
onValidateObject,
|
|
450
|
+
forID,
|
|
451
|
+
fieldsErrors,
|
|
452
|
+
} = this.props;
|
|
453
|
+
|
|
435
454
|
const collectionName = field.get('name');
|
|
436
455
|
const isSingleField = this.getValueType() === valueTypes.SINGLE;
|
|
437
456
|
|
|
@@ -441,17 +460,41 @@ export default class ListControl extends React.Component {
|
|
|
441
460
|
? { [collectionName]: metadata.removeIn(metadataRemovePath) }
|
|
442
461
|
: metadata;
|
|
443
462
|
|
|
463
|
+
// Get the key of the item being removed
|
|
464
|
+
const removedKey = this.state.keys[index];
|
|
465
|
+
|
|
466
|
+
// Update state while preserving keys for remaining items
|
|
467
|
+
const newKeys = [...this.state.keys];
|
|
468
|
+
newKeys.splice(index, 1);
|
|
444
469
|
itemsCollapsed.splice(index, 1);
|
|
445
|
-
// clear validations
|
|
446
|
-
this.validations = [];
|
|
447
470
|
|
|
448
471
|
this.setState({
|
|
449
472
|
itemsCollapsed: [...itemsCollapsed],
|
|
450
|
-
keys:
|
|
473
|
+
keys: newKeys,
|
|
451
474
|
});
|
|
452
475
|
|
|
453
|
-
|
|
454
|
-
|
|
476
|
+
// Clear the ref for the removed item
|
|
477
|
+
delete this.childRefs[removedKey];
|
|
478
|
+
|
|
479
|
+
const newValue = value.delete(index);
|
|
480
|
+
|
|
481
|
+
// Clear errors for the removed item and its children
|
|
482
|
+
if (fieldsErrors) {
|
|
483
|
+
Object.entries(fieldsErrors.toJS()).forEach(([fieldId, errors]) => {
|
|
484
|
+
if (errors.some(err => err.parentIds?.includes(removedKey))) {
|
|
485
|
+
clearFieldErrors(fieldId);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// If list is empty, mark it as valid
|
|
491
|
+
if (newValue.size === 0) {
|
|
492
|
+
clearFieldErrors(forID);
|
|
493
|
+
onValidateObject(forID, []);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Update the value last to ensure all error states are cleared
|
|
497
|
+
onChange(newValue, parsedMetadata);
|
|
455
498
|
};
|
|
456
499
|
|
|
457
500
|
handleItemCollapseToggle = (index, event) => {
|
|
@@ -527,7 +570,7 @@ export default class ListControl extends React.Component {
|
|
|
527
570
|
}
|
|
528
571
|
|
|
529
572
|
onSortEnd = ({ oldIndex, newIndex }) => {
|
|
530
|
-
const { value
|
|
573
|
+
const { value } = this.props;
|
|
531
574
|
const { itemsCollapsed, keys } = this.state;
|
|
532
575
|
|
|
533
576
|
// Update value
|
|
@@ -541,18 +584,13 @@ export default class ListControl extends React.Component {
|
|
|
541
584
|
const updatedItemsCollapsed = [...itemsCollapsed];
|
|
542
585
|
updatedItemsCollapsed.splice(newIndex, 0, collapsed);
|
|
543
586
|
|
|
544
|
-
//
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return key;
|
|
550
|
-
});
|
|
551
|
-
this.setState({ itemsCollapsed: updatedItemsCollapsed, keys: updatedKeys });
|
|
587
|
+
// Move keys to maintain relationships
|
|
588
|
+
const movedKey = keys[oldIndex];
|
|
589
|
+
const updatedKeys = [...keys];
|
|
590
|
+
updatedKeys.splice(oldIndex, 1);
|
|
591
|
+
updatedKeys.splice(newIndex, 0, movedKey);
|
|
552
592
|
|
|
553
|
-
|
|
554
|
-
clearFieldErrors();
|
|
555
|
-
this.validations = this.validations.filter(item => updatedKeys.includes(item.key));
|
|
593
|
+
this.setState({ itemsCollapsed: updatedItemsCollapsed, keys: updatedKeys });
|
|
556
594
|
};
|
|
557
595
|
|
|
558
596
|
hasError = index => {
|
|
@@ -564,6 +602,34 @@ export default class ListControl extends React.Component {
|
|
|
564
602
|
}
|
|
565
603
|
};
|
|
566
604
|
|
|
605
|
+
focus(path) {
|
|
606
|
+
const [index, ...remainingPath] = path.split('.');
|
|
607
|
+
|
|
608
|
+
if (this.state.listCollapsed || this.state.itemsCollapsed[index]) {
|
|
609
|
+
const newItemsCollapsed = [...this.state.itemsCollapsed];
|
|
610
|
+
newItemsCollapsed[index] = false;
|
|
611
|
+
this.setState(
|
|
612
|
+
{
|
|
613
|
+
listCollapsed: false,
|
|
614
|
+
itemsCollapsed: newItemsCollapsed,
|
|
615
|
+
},
|
|
616
|
+
() => {
|
|
617
|
+
const key = this.state.keys[index];
|
|
618
|
+
const control = this.childRefs[key];
|
|
619
|
+
if (control?.focus) {
|
|
620
|
+
control.focus(remainingPath.join('.'));
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
);
|
|
624
|
+
} else {
|
|
625
|
+
const key = this.state.keys[index];
|
|
626
|
+
const control = this.childRefs[key];
|
|
627
|
+
if (control?.focus) {
|
|
628
|
+
control.focus(remainingPath.join('.'));
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
567
633
|
// eslint-disable-next-line react/display-name
|
|
568
634
|
renderItem = (item, index) => {
|
|
569
635
|
const {
|
|
@@ -104,11 +104,11 @@ describe('ListControl', () => {
|
|
|
104
104
|
/>,
|
|
105
105
|
);
|
|
106
106
|
|
|
107
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
108
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
107
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
108
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
109
109
|
|
|
110
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
111
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
110
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
111
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
112
112
|
|
|
113
113
|
expect(asFragment()).toMatchSnapshot();
|
|
114
114
|
});
|
|
@@ -133,11 +133,11 @@ describe('ListControl', () => {
|
|
|
133
133
|
/>,
|
|
134
134
|
);
|
|
135
135
|
|
|
136
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
137
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
136
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
137
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
138
138
|
|
|
139
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
140
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
139
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
140
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
141
141
|
|
|
142
142
|
expect(asFragment()).toMatchSnapshot();
|
|
143
143
|
});
|
|
@@ -162,19 +162,19 @@ describe('ListControl', () => {
|
|
|
162
162
|
/>,
|
|
163
163
|
);
|
|
164
164
|
|
|
165
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
166
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
165
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
166
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
167
167
|
|
|
168
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
169
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
168
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
169
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
170
170
|
|
|
171
171
|
fireEvent.click(getByTestId('expand-button'));
|
|
172
172
|
|
|
173
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
174
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
173
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
174
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
175
175
|
|
|
176
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
177
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
176
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
177
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
it('should collapse a single item on collapse item click', () => {
|
|
@@ -197,19 +197,19 @@ describe('ListControl', () => {
|
|
|
197
197
|
/>,
|
|
198
198
|
);
|
|
199
199
|
|
|
200
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
201
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
200
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
201
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
202
202
|
|
|
203
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
204
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
203
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
204
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
205
205
|
|
|
206
206
|
fireEvent.click(getByTestId('styled-list-item-top-bar-0'));
|
|
207
207
|
|
|
208
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
209
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
208
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
209
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
210
210
|
|
|
211
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
212
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
211
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
212
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
it('should expand all items on top bar expand click', () => {
|
|
@@ -232,19 +232,19 @@ describe('ListControl', () => {
|
|
|
232
232
|
/>,
|
|
233
233
|
);
|
|
234
234
|
|
|
235
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
236
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
235
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
236
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
237
237
|
|
|
238
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
239
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
238
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
239
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
240
240
|
|
|
241
241
|
fireEvent.click(getByTestId('expand-button'));
|
|
242
242
|
|
|
243
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
244
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
243
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
244
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
245
245
|
|
|
246
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
247
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
246
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
247
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
it('should expand a single item on expand item click', () => {
|
|
@@ -267,19 +267,19 @@ describe('ListControl', () => {
|
|
|
267
267
|
/>,
|
|
268
268
|
);
|
|
269
269
|
|
|
270
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
271
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
270
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
271
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
272
272
|
|
|
273
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
274
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
273
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
274
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
275
275
|
|
|
276
276
|
fireEvent.click(getByTestId('styled-list-item-top-bar-0'));
|
|
277
277
|
|
|
278
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
279
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
278
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
279
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
280
280
|
|
|
281
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
282
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
281
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
282
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
283
283
|
});
|
|
284
284
|
|
|
285
285
|
it('should use widget name when no summary or label are configured for mixed types', () => {
|
|
@@ -477,11 +477,11 @@ describe('ListControl', () => {
|
|
|
477
477
|
/>,
|
|
478
478
|
);
|
|
479
479
|
|
|
480
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
481
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
480
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
481
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
482
482
|
|
|
483
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
484
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
483
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
484
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
485
485
|
|
|
486
486
|
expect(asFragment()).toMatchSnapshot();
|
|
487
487
|
});
|
|
@@ -501,11 +501,11 @@ describe('ListControl', () => {
|
|
|
501
501
|
/>,
|
|
502
502
|
);
|
|
503
503
|
|
|
504
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
505
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
504
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
505
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
506
506
|
|
|
507
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
508
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
507
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
508
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
509
509
|
|
|
510
510
|
expect(asFragment()).toMatchSnapshot();
|
|
511
511
|
});
|
|
@@ -535,11 +535,11 @@ describe('ListControl', () => {
|
|
|
535
535
|
|
|
536
536
|
fireEvent.click(getByTestId('expand-button'));
|
|
537
537
|
|
|
538
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
539
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
538
|
+
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed');
|
|
539
|
+
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed');
|
|
540
540
|
|
|
541
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
542
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
541
|
+
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed');
|
|
542
|
+
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed');
|
|
543
543
|
});
|
|
544
544
|
|
|
545
545
|
it('should render list with fields with collapse = "false" and default minimize_collapsed = "true"', () => {
|
|
@@ -558,11 +558,11 @@ describe('ListControl', () => {
|
|
|
558
558
|
/>,
|
|
559
559
|
);
|
|
560
560
|
|
|
561
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
562
|
-
expect(getByTestId('styled-list-item-top-bar-1')).toHaveAttribute('collapsed'
|
|
561
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
562
|
+
expect(getByTestId('styled-list-item-top-bar-1')).not.toHaveAttribute('collapsed');
|
|
563
563
|
|
|
564
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
565
|
-
expect(getByTestId('object-control-1')).toHaveAttribute('collapsed'
|
|
564
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
565
|
+
expect(getByTestId('object-control-1')).not.toHaveAttribute('collapsed');
|
|
566
566
|
|
|
567
567
|
expect(asFragment()).toMatchSnapshot();
|
|
568
568
|
|
|
@@ -594,8 +594,8 @@ describe('ListControl', () => {
|
|
|
594
594
|
|
|
595
595
|
rerender(<ListControl {...props} field={field} value={fromJS([{}])} />);
|
|
596
596
|
|
|
597
|
-
expect(getByTestId('styled-list-item-top-bar-0')).toHaveAttribute('collapsed'
|
|
598
|
-
expect(getByTestId('object-control-0')).toHaveAttribute('collapsed'
|
|
597
|
+
expect(getByTestId('styled-list-item-top-bar-0')).not.toHaveAttribute('collapsed');
|
|
598
|
+
expect(getByTestId('object-control-0')).not.toHaveAttribute('collapsed');
|
|
599
599
|
|
|
600
600
|
expect(asFragment()).toMatchSnapshot();
|
|
601
601
|
});
|