decap-cms-widget-list 3.4.0 → 3.6.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.
@@ -3,6 +3,12 @@ export default {
3
3
  allow_add: {
4
4
  type: 'boolean'
5
5
  },
6
+ allow_remove: {
7
+ type: 'boolean'
8
+ },
9
+ allow_reorder: {
10
+ type: 'boolean'
11
+ },
6
12
  collapsed: {
7
13
  type: 'boolean'
8
14
  },
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.0",
4
+ "version": "3.6.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",
@@ -23,7 +23,8 @@
23
23
  "dependencies": {
24
24
  "@dnd-kit/core": "^6.0.8",
25
25
  "@dnd-kit/modifiers": "^6.0.1",
26
- "@dnd-kit/sortable": "^7.0.2"
26
+ "@dnd-kit/sortable": "^7.0.2",
27
+ "@dnd-kit/utilities": "^3.2.2"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "@emotion/react": "^11.11.1",
@@ -37,5 +38,5 @@
37
38
  "react": "^19.1.0",
38
39
  "react-immutable-proptypes": "^2.1.0"
39
40
  },
40
- "gitHead": "ed7e99318007b83f4c57f3237bf92b931676820a"
41
+ "gitHead": "567a80101f4846853701ad7d8abdc29b5e4fab56"
41
42
  }
@@ -7,7 +7,6 @@ import { List, Map, fromJS } from 'immutable';
7
7
  import partial from 'lodash/partial';
8
8
  import isEmpty from 'lodash/isEmpty';
9
9
  import uniqueId from 'lodash/uniqueId';
10
- import { v4 as uuid } from 'uuid';
11
10
  import DecapCmsWidgetObject from 'decap-cms-widget-object';
12
11
  import {
13
12
  DndContext,
@@ -211,7 +210,7 @@ export default class ListControl extends React.Component {
211
210
  const { field, value } = props;
212
211
  const listCollapsed = field.get('collapsed', true);
213
212
  const itemsCollapsed = (value && Array(value.size).fill(listCollapsed)) || [];
214
- const keys = (value && Array.from({ length: value.size }, () => uuid())) || [];
213
+ const keys = (value && Array.from({ length: value.size }, () => crypto.randomUUID())) || [];
215
214
 
216
215
  this.state = {
217
216
  listCollapsed,
@@ -353,7 +352,7 @@ export default class ListControl extends React.Component {
353
352
  const { value, onChange, field } = this.props;
354
353
  const addToTop = field.get('add_to_top', false);
355
354
 
356
- const itemKey = uuid();
355
+ const itemKey = crypto.randomUUID();
357
356
  this.setState({
358
357
  itemsCollapsed: addToTop
359
358
  ? [false, ...this.state.itemsCollapsed]
@@ -682,6 +681,8 @@ export default class ListControl extends React.Component {
682
681
  onCollapseToggle={partial(this.handleItemCollapseToggle, index)}
683
682
  dragHandle={DragHandle}
684
683
  id={key}
684
+ allowRemove={field.get('allow_remove', true)}
685
+ allowReorder={field.get('allow_reorder', true)}
685
686
  onRemove={partial(this.handleRemove, index)}
686
687
  data-testid={`styled-list-item-top-bar-${key}`}
687
688
  />
@@ -34,7 +34,6 @@ jest.mock('decap-cms-ui-default', () => {
34
34
  ListItemTopBar,
35
35
  };
36
36
  });
37
- jest.mock('uuid');
38
37
 
39
38
  describe('ListControl', () => {
40
39
  const props = {
@@ -63,9 +62,8 @@ describe('ListControl', () => {
63
62
 
64
63
  beforeEach(() => {
65
64
  jest.clearAllMocks();
66
- const uuid = require('uuid');
67
65
  let id = 0;
68
- uuid.v4.mockImplementation(() => {
66
+ global.crypto.randomUUID = jest.fn(() => {
69
67
  return id++;
70
68
  });
71
69
  });
@@ -162,6 +162,7 @@ exports[`ListControl should add to list when add button is clicked 1`] = `
162
162
  class="emotion-3 emotion-4"
163
163
  >
164
164
  <button
165
+ aria-label="editor.editorWidgets.object.collapse"
165
166
  class="emotion-5 emotion-6"
166
167
  data-testid="expand-button"
167
168
  >
@@ -204,6 +205,8 @@ exports[`ListControl should add to list when add button is clicked 1`] = `
204
205
  class="emotion-15 emotion-16"
205
206
  >
206
207
  <mock-list-item-top-bar
208
+ allowremove=""
209
+ allowreorder=""
207
210
  class="emotion-17 emotion-18"
208
211
  data-testid="styled-list-item-top-bar-0"
209
212
  id="0"
@@ -412,6 +415,7 @@ exports[`ListControl should remove from list when remove button is clicked 1`] =
412
415
  class="emotion-3 emotion-4"
413
416
  >
414
417
  <button
418
+ aria-label="editor.editorWidgets.object.collapse"
415
419
  class="emotion-5 emotion-6"
416
420
  data-testid="expand-button"
417
421
  >
@@ -454,6 +458,8 @@ exports[`ListControl should remove from list when remove button is clicked 1`] =
454
458
  class="emotion-15 emotion-16"
455
459
  >
456
460
  <mock-list-item-top-bar
461
+ allowremove=""
462
+ allowreorder=""
457
463
  class="emotion-17 emotion-18"
458
464
  data-testid="styled-list-item-top-bar-0"
459
465
  id="0"
@@ -482,6 +488,8 @@ exports[`ListControl should remove from list when remove button is clicked 1`] =
482
488
  class="emotion-15 emotion-16"
483
489
  >
484
490
  <mock-list-item-top-bar
491
+ allowremove=""
492
+ allowreorder=""
485
493
  class="emotion-17 emotion-18"
486
494
  data-testid="styled-list-item-top-bar-1"
487
495
  id="1"
@@ -690,6 +698,7 @@ exports[`ListControl should remove from list when remove button is clicked 2`] =
690
698
  class="emotion-3 emotion-4"
691
699
  >
692
700
  <button
701
+ aria-label="editor.editorWidgets.object.collapse"
693
702
  class="emotion-5 emotion-6"
694
703
  data-testid="expand-button"
695
704
  >
@@ -732,6 +741,8 @@ exports[`ListControl should remove from list when remove button is clicked 2`] =
732
741
  class="emotion-15 emotion-16"
733
742
  >
734
743
  <mock-list-item-top-bar
744
+ allowremove=""
745
+ allowreorder=""
735
746
  class="emotion-17 emotion-18"
736
747
  collapsed=""
737
748
  data-testid="styled-list-item-top-bar-1"
@@ -953,6 +964,7 @@ exports[`ListControl should render list with fields with collapse = "false" and
953
964
  class="emotion-3 emotion-4"
954
965
  >
955
966
  <button
967
+ aria-label="editor.editorWidgets.object.collapse"
956
968
  class="emotion-5 emotion-6"
957
969
  data-testid="expand-button"
958
970
  >
@@ -995,6 +1007,8 @@ exports[`ListControl should render list with fields with collapse = "false" and
995
1007
  class="emotion-15 emotion-16"
996
1008
  >
997
1009
  <mock-list-item-top-bar
1010
+ allowremove=""
1011
+ allowreorder=""
998
1012
  class="emotion-17 emotion-18"
999
1013
  data-testid="styled-list-item-top-bar-0"
1000
1014
  id="0"
@@ -1023,6 +1037,8 @@ exports[`ListControl should render list with fields with collapse = "false" and
1023
1037
  class="emotion-15 emotion-16"
1024
1038
  >
1025
1039
  <mock-list-item-top-bar
1040
+ allowremove=""
1041
+ allowreorder=""
1026
1042
  class="emotion-17 emotion-18"
1027
1043
  data-testid="styled-list-item-top-bar-1"
1028
1044
  id="1"
@@ -1231,6 +1247,7 @@ exports[`ListControl should render list with fields with collapse = "false" and
1231
1247
  class="emotion-3 emotion-4"
1232
1248
  >
1233
1249
  <button
1250
+ aria-label="editor.editorWidgets.object.collapse"
1234
1251
  class="emotion-5 emotion-6"
1235
1252
  data-testid="expand-button"
1236
1253
  >
@@ -1273,6 +1290,8 @@ exports[`ListControl should render list with fields with collapse = "false" and
1273
1290
  class="emotion-15 emotion-16"
1274
1291
  >
1275
1292
  <mock-list-item-top-bar
1293
+ allowremove=""
1294
+ allowreorder=""
1276
1295
  class="emotion-17 emotion-18"
1277
1296
  data-testid="styled-list-item-top-bar-0"
1278
1297
  id="0"
@@ -1301,6 +1320,8 @@ exports[`ListControl should render list with fields with collapse = "false" and
1301
1320
  class="emotion-15 emotion-16"
1302
1321
  >
1303
1322
  <mock-list-item-top-bar
1323
+ allowremove=""
1324
+ allowreorder=""
1304
1325
  class="emotion-17 emotion-18"
1305
1326
  data-testid="styled-list-item-top-bar-1"
1306
1327
  id="1"
@@ -1509,6 +1530,7 @@ exports[`ListControl should render list with fields with default collapse ("true
1509
1530
  class="emotion-3 emotion-4"
1510
1531
  >
1511
1532
  <button
1533
+ aria-label="editor.editorWidgets.object.expand"
1512
1534
  class="emotion-5 emotion-6"
1513
1535
  data-testid="expand-button"
1514
1536
  >
@@ -1551,6 +1573,8 @@ exports[`ListControl should render list with fields with default collapse ("true
1551
1573
  class="emotion-15 emotion-16"
1552
1574
  >
1553
1575
  <mock-list-item-top-bar
1576
+ allowremove=""
1577
+ allowreorder=""
1554
1578
  class="emotion-17 emotion-18"
1555
1579
  collapsed=""
1556
1580
  data-testid="styled-list-item-top-bar-0"
@@ -1581,6 +1605,8 @@ exports[`ListControl should render list with fields with default collapse ("true
1581
1605
  class="emotion-15 emotion-16"
1582
1606
  >
1583
1607
  <mock-list-item-top-bar
1608
+ allowremove=""
1609
+ allowreorder=""
1584
1610
  class="emotion-17 emotion-18"
1585
1611
  collapsed=""
1586
1612
  data-testid="styled-list-item-top-bar-1"
@@ -1770,6 +1796,7 @@ exports[`ListControl should render list with fields with default collapse ("true
1770
1796
  class="emotion-3 emotion-4"
1771
1797
  >
1772
1798
  <button
1799
+ aria-label="editor.editorWidgets.object.expand"
1773
1800
  class="emotion-5 emotion-6"
1774
1801
  data-testid="expand-button"
1775
1802
  >
@@ -1973,6 +2000,7 @@ exports[`ListControl should render list with nested object 1`] = `
1973
2000
  class="emotion-3 emotion-4"
1974
2001
  >
1975
2002
  <button
2003
+ aria-label="editor.editorWidgets.object.expand"
1976
2004
  class="emotion-5 emotion-6"
1977
2005
  data-testid="expand-button"
1978
2006
  >
@@ -2015,6 +2043,8 @@ exports[`ListControl should render list with nested object 1`] = `
2015
2043
  class="emotion-15 emotion-16"
2016
2044
  >
2017
2045
  <mock-list-item-top-bar
2046
+ allowremove=""
2047
+ allowreorder=""
2018
2048
  class="emotion-17 emotion-18"
2019
2049
  collapsed=""
2020
2050
  data-testid="styled-list-item-top-bar-0"
@@ -2045,6 +2075,8 @@ exports[`ListControl should render list with nested object 1`] = `
2045
2075
  class="emotion-15 emotion-16"
2046
2076
  >
2047
2077
  <mock-list-item-top-bar
2078
+ allowremove=""
2079
+ allowreorder=""
2048
2080
  class="emotion-17 emotion-18"
2049
2081
  collapsed=""
2050
2082
  data-testid="styled-list-item-top-bar-1"
@@ -2255,6 +2287,7 @@ exports[`ListControl should render list with nested object with collapse = false
2255
2287
  class="emotion-3 emotion-4"
2256
2288
  >
2257
2289
  <button
2290
+ aria-label="editor.editorWidgets.object.collapse"
2258
2291
  class="emotion-5 emotion-6"
2259
2292
  data-testid="expand-button"
2260
2293
  >
@@ -2297,6 +2330,8 @@ exports[`ListControl should render list with nested object with collapse = false
2297
2330
  class="emotion-15 emotion-16"
2298
2331
  >
2299
2332
  <mock-list-item-top-bar
2333
+ allowremove=""
2334
+ allowreorder=""
2300
2335
  class="emotion-17 emotion-18"
2301
2336
  data-testid="styled-list-item-top-bar-0"
2302
2337
  id="0"
@@ -2325,6 +2360,8 @@ exports[`ListControl should render list with nested object with collapse = false
2325
2360
  class="emotion-15 emotion-16"
2326
2361
  >
2327
2362
  <mock-list-item-top-bar
2363
+ allowremove=""
2364
+ allowreorder=""
2328
2365
  class="emotion-17 emotion-18"
2329
2366
  data-testid="styled-list-item-top-bar-1"
2330
2367
  id="1"
package/src/schema.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export default {
2
2
  properties: {
3
3
  allow_add: { type: 'boolean' },
4
+ allow_remove: { type: 'boolean' },
5
+ allow_reorder: { type: 'boolean' },
4
6
  collapsed: { type: 'boolean' },
5
7
  summary: { type: 'string' },
6
8
  minimize_collapsed: { type: 'boolean' },