@geekron/strapi 0.2.4 → 0.2.6
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/dist/admin/index.js +64 -22
- package/dist/admin/index.mjs +64 -22
- package/dist/server/index.js +23 -0
- package/dist/server/index.mjs +23 -0
- package/package.json +1 -1
package/dist/admin/index.js
CHANGED
|
@@ -46738,7 +46738,7 @@ function getMinDepth(nextItem) {
|
|
|
46738
46738
|
}
|
|
46739
46739
|
return 0;
|
|
46740
46740
|
}
|
|
46741
|
-
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
46741
|
+
function getProjection(items, activeId, overId, dragOffset, indentationWidth, configMaxDepth) {
|
|
46742
46742
|
const overItemIndex = items.findIndex(({ id }) => id === overId);
|
|
46743
46743
|
const activeItemIndex = items.findIndex(({ id }) => id === activeId);
|
|
46744
46744
|
const activeItem = items[activeItemIndex];
|
|
@@ -46750,8 +46750,11 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
46750
46750
|
const nextItem = newItems[overItemIndex + 1];
|
|
46751
46751
|
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
46752
46752
|
const projectedDepth = activeItem.depth + dragDepth;
|
|
46753
|
-
|
|
46753
|
+
let maxDepth = getMaxDepth(previousItem);
|
|
46754
46754
|
const minDepth = getMinDepth(nextItem);
|
|
46755
|
+
if (configMaxDepth !== undefined && maxDepth >= configMaxDepth) {
|
|
46756
|
+
maxDepth = configMaxDepth - 1;
|
|
46757
|
+
}
|
|
46755
46758
|
let depth = projectedDepth;
|
|
46756
46759
|
if (projectedDepth >= maxDepth) {
|
|
46757
46760
|
depth = maxDepth;
|
|
@@ -46826,29 +46829,32 @@ function findItemDeep(items, itemId) {
|
|
|
46826
46829
|
return;
|
|
46827
46830
|
}
|
|
46828
46831
|
function removeItem(items, id) {
|
|
46829
|
-
|
|
46830
|
-
for (const item of items) {
|
|
46831
|
-
if (item.id === id) {
|
|
46832
|
-
continue;
|
|
46833
|
-
}
|
|
46832
|
+
return items.filter((item) => item.id !== id).map((item) => {
|
|
46834
46833
|
if (item.children.length) {
|
|
46835
|
-
|
|
46834
|
+
return {
|
|
46835
|
+
...item,
|
|
46836
|
+
children: removeItem(item.children, id)
|
|
46837
|
+
};
|
|
46836
46838
|
}
|
|
46837
|
-
|
|
46838
|
-
}
|
|
46839
|
-
return newItems;
|
|
46839
|
+
return item;
|
|
46840
|
+
});
|
|
46840
46841
|
}
|
|
46841
46842
|
function setProperty(items, id, property, setter) {
|
|
46842
|
-
|
|
46843
|
+
return items.map((item) => {
|
|
46843
46844
|
if (item.id === id) {
|
|
46844
|
-
|
|
46845
|
-
|
|
46845
|
+
return {
|
|
46846
|
+
...item,
|
|
46847
|
+
[property]: setter(item[property])
|
|
46848
|
+
};
|
|
46846
46849
|
}
|
|
46847
46850
|
if (item.children.length) {
|
|
46848
|
-
|
|
46851
|
+
return {
|
|
46852
|
+
...item,
|
|
46853
|
+
children: setProperty(item.children, id, property, setter)
|
|
46854
|
+
};
|
|
46849
46855
|
}
|
|
46850
|
-
|
|
46851
|
-
|
|
46856
|
+
return item;
|
|
46857
|
+
});
|
|
46852
46858
|
}
|
|
46853
46859
|
function countChildren(items, count = 0) {
|
|
46854
46860
|
return items.reduce((acc, { children }) => {
|
|
@@ -47214,7 +47220,7 @@ var adjustTranslate = ({ transform }) => {
|
|
|
47214
47220
|
};
|
|
47215
47221
|
// admin/src/fields/DataNested/hooks/useTreeItems.ts
|
|
47216
47222
|
var import_react7 = require("react");
|
|
47217
|
-
function useTreeItems(defaultItems) {
|
|
47223
|
+
function useTreeItems(defaultItems, maxDepth) {
|
|
47218
47224
|
const [items, setItems] = import_react7.useState(() => defaultItems);
|
|
47219
47225
|
const [modalState, setModalState] = import_react7.useState({
|
|
47220
47226
|
isOpen: false,
|
|
@@ -47245,6 +47251,12 @@ function useTreeItems(defaultItems) {
|
|
|
47245
47251
|
});
|
|
47246
47252
|
};
|
|
47247
47253
|
const handleAddChild = (id) => {
|
|
47254
|
+
if (maxDepth !== undefined) {
|
|
47255
|
+
const itemDepth = getItemDepth(items, id);
|
|
47256
|
+
if (itemDepth >= maxDepth - 1) {
|
|
47257
|
+
return;
|
|
47258
|
+
}
|
|
47259
|
+
}
|
|
47248
47260
|
setModalState({
|
|
47249
47261
|
isOpen: true,
|
|
47250
47262
|
mode: "add",
|
|
@@ -47327,6 +47339,21 @@ function findItemDeep2(items, itemId) {
|
|
|
47327
47339
|
}
|
|
47328
47340
|
return;
|
|
47329
47341
|
}
|
|
47342
|
+
function getItemDepth(items, itemId, depth = 0) {
|
|
47343
|
+
for (const item of items) {
|
|
47344
|
+
const { id, children } = item;
|
|
47345
|
+
if (id === itemId) {
|
|
47346
|
+
return depth;
|
|
47347
|
+
}
|
|
47348
|
+
if (children.length) {
|
|
47349
|
+
const childDepth = getItemDepth(children, itemId, depth + 1);
|
|
47350
|
+
if (childDepth !== -1) {
|
|
47351
|
+
return childDepth;
|
|
47352
|
+
}
|
|
47353
|
+
}
|
|
47354
|
+
}
|
|
47355
|
+
return -1;
|
|
47356
|
+
}
|
|
47330
47357
|
// admin/src/fields/DataNested/keyboardCoordinates.ts
|
|
47331
47358
|
var import_core = __toESM(require_dist3(), 1);
|
|
47332
47359
|
|
|
@@ -47499,6 +47526,7 @@ function SortableTree({
|
|
|
47499
47526
|
indicator = false,
|
|
47500
47527
|
indentationWidth = DEFAULT_INDENTATION_WIDTH,
|
|
47501
47528
|
removable,
|
|
47529
|
+
maxDepth,
|
|
47502
47530
|
onChange
|
|
47503
47531
|
}) {
|
|
47504
47532
|
const {
|
|
@@ -47514,7 +47542,7 @@ function SortableTree({
|
|
|
47514
47542
|
handleModalClose,
|
|
47515
47543
|
handleModalSubmit,
|
|
47516
47544
|
getInitialData
|
|
47517
|
-
} = useTreeItems(defaultItems);
|
|
47545
|
+
} = useTreeItems(defaultItems, maxDepth);
|
|
47518
47546
|
const [activeId, setActiveId] = import_react8.useState(null);
|
|
47519
47547
|
const flattenedItems = import_react8.useMemo(() => {
|
|
47520
47548
|
const flattenedTree = flattenTree(items);
|
|
@@ -47534,7 +47562,7 @@ function SortableTree({
|
|
|
47534
47562
|
handleDragOver,
|
|
47535
47563
|
handleDragCancel
|
|
47536
47564
|
} = useDragState(flattenedItems, setActiveId);
|
|
47537
|
-
const projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth) : null;
|
|
47565
|
+
const projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth, maxDepth) : null;
|
|
47538
47566
|
const sensorContext = import_react8.useRef({
|
|
47539
47567
|
items: flattenedItems,
|
|
47540
47568
|
offset: offsetLeft
|
|
@@ -47614,7 +47642,7 @@ function SortableTree({
|
|
|
47614
47642
|
collapsed: Boolean(collapsed && children.length),
|
|
47615
47643
|
onCollapse: collapsible && children.length ? () => handleCollapse(id) : undefined,
|
|
47616
47644
|
onAddSibling: () => handleAddSibling(id),
|
|
47617
|
-
onAddChild: () => handleAddChild(id),
|
|
47645
|
+
onAddChild: maxDepth !== undefined && depth >= maxDepth - 1 ? undefined : () => handleAddChild(id),
|
|
47618
47646
|
onEdit: () => handleEdit(id),
|
|
47619
47647
|
onRemove: removable ? () => handleRemove(id) : undefined
|
|
47620
47648
|
}, id, false, undefined, this)),
|
|
@@ -47650,7 +47678,8 @@ var DataNested = ({
|
|
|
47650
47678
|
name,
|
|
47651
47679
|
label,
|
|
47652
47680
|
hint,
|
|
47653
|
-
required
|
|
47681
|
+
required,
|
|
47682
|
+
attribute
|
|
47654
47683
|
}) => {
|
|
47655
47684
|
const field = import_admin3.useField(name);
|
|
47656
47685
|
const handleChange = (value) => {
|
|
@@ -47671,6 +47700,7 @@ var DataNested = ({
|
|
|
47671
47700
|
indicator: true,
|
|
47672
47701
|
removable: true,
|
|
47673
47702
|
defaultItems: field.value || [],
|
|
47703
|
+
maxDepth: attribute.options?.depth,
|
|
47674
47704
|
onChange: handleChange
|
|
47675
47705
|
}, undefined, false, undefined, this),
|
|
47676
47706
|
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(import_design_system5.Field.Hint, {}, undefined, false, undefined, this),
|
|
@@ -47708,6 +47738,18 @@ var registerDataNested = (app) => {
|
|
|
47708
47738
|
id: "form.attribute.item.requiredField.description",
|
|
47709
47739
|
defaultMessage: "Cannot create entry if empty"
|
|
47710
47740
|
}
|
|
47741
|
+
},
|
|
47742
|
+
{
|
|
47743
|
+
name: "options.depth",
|
|
47744
|
+
type: "number",
|
|
47745
|
+
intlLabel: {
|
|
47746
|
+
id: `${pluginId}.fields.dataNested.options.depthField.label`,
|
|
47747
|
+
defaultMessage: "Nested max depth"
|
|
47748
|
+
},
|
|
47749
|
+
description: {
|
|
47750
|
+
id: `${pluginId}.fields.dataNested.options.depthField.description`,
|
|
47751
|
+
defaultMessage: "Maximum depth of nested items"
|
|
47752
|
+
}
|
|
47711
47753
|
}
|
|
47712
47754
|
]
|
|
47713
47755
|
}
|
package/dist/admin/index.mjs
CHANGED
|
@@ -46783,7 +46783,7 @@ function getMinDepth(nextItem) {
|
|
|
46783
46783
|
}
|
|
46784
46784
|
return 0;
|
|
46785
46785
|
}
|
|
46786
|
-
function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
46786
|
+
function getProjection(items, activeId, overId, dragOffset, indentationWidth, configMaxDepth) {
|
|
46787
46787
|
const overItemIndex = items.findIndex(({ id }) => id === overId);
|
|
46788
46788
|
const activeItemIndex = items.findIndex(({ id }) => id === activeId);
|
|
46789
46789
|
const activeItem = items[activeItemIndex];
|
|
@@ -46795,8 +46795,11 @@ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
|
46795
46795
|
const nextItem = newItems[overItemIndex + 1];
|
|
46796
46796
|
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
46797
46797
|
const projectedDepth = activeItem.depth + dragDepth;
|
|
46798
|
-
|
|
46798
|
+
let maxDepth = getMaxDepth(previousItem);
|
|
46799
46799
|
const minDepth = getMinDepth(nextItem);
|
|
46800
|
+
if (configMaxDepth !== undefined && maxDepth >= configMaxDepth) {
|
|
46801
|
+
maxDepth = configMaxDepth - 1;
|
|
46802
|
+
}
|
|
46800
46803
|
let depth = projectedDepth;
|
|
46801
46804
|
if (projectedDepth >= maxDepth) {
|
|
46802
46805
|
depth = maxDepth;
|
|
@@ -46871,29 +46874,32 @@ function findItemDeep(items, itemId) {
|
|
|
46871
46874
|
return;
|
|
46872
46875
|
}
|
|
46873
46876
|
function removeItem(items, id) {
|
|
46874
|
-
|
|
46875
|
-
for (const item of items) {
|
|
46876
|
-
if (item.id === id) {
|
|
46877
|
-
continue;
|
|
46878
|
-
}
|
|
46877
|
+
return items.filter((item) => item.id !== id).map((item) => {
|
|
46879
46878
|
if (item.children.length) {
|
|
46880
|
-
|
|
46879
|
+
return {
|
|
46880
|
+
...item,
|
|
46881
|
+
children: removeItem(item.children, id)
|
|
46882
|
+
};
|
|
46881
46883
|
}
|
|
46882
|
-
|
|
46883
|
-
}
|
|
46884
|
-
return newItems;
|
|
46884
|
+
return item;
|
|
46885
|
+
});
|
|
46885
46886
|
}
|
|
46886
46887
|
function setProperty(items, id, property, setter) {
|
|
46887
|
-
|
|
46888
|
+
return items.map((item) => {
|
|
46888
46889
|
if (item.id === id) {
|
|
46889
|
-
|
|
46890
|
-
|
|
46890
|
+
return {
|
|
46891
|
+
...item,
|
|
46892
|
+
[property]: setter(item[property])
|
|
46893
|
+
};
|
|
46891
46894
|
}
|
|
46892
46895
|
if (item.children.length) {
|
|
46893
|
-
|
|
46896
|
+
return {
|
|
46897
|
+
...item,
|
|
46898
|
+
children: setProperty(item.children, id, property, setter)
|
|
46899
|
+
};
|
|
46894
46900
|
}
|
|
46895
|
-
|
|
46896
|
-
|
|
46901
|
+
return item;
|
|
46902
|
+
});
|
|
46897
46903
|
}
|
|
46898
46904
|
function countChildren(items, count = 0) {
|
|
46899
46905
|
return items.reduce((acc, { children }) => {
|
|
@@ -47259,7 +47265,7 @@ var adjustTranslate = ({ transform }) => {
|
|
|
47259
47265
|
};
|
|
47260
47266
|
// admin/src/fields/DataNested/hooks/useTreeItems.ts
|
|
47261
47267
|
import { useState as useState6 } from "react";
|
|
47262
|
-
function useTreeItems(defaultItems) {
|
|
47268
|
+
function useTreeItems(defaultItems, maxDepth) {
|
|
47263
47269
|
const [items, setItems] = useState6(() => defaultItems);
|
|
47264
47270
|
const [modalState, setModalState] = useState6({
|
|
47265
47271
|
isOpen: false,
|
|
@@ -47290,6 +47296,12 @@ function useTreeItems(defaultItems) {
|
|
|
47290
47296
|
});
|
|
47291
47297
|
};
|
|
47292
47298
|
const handleAddChild = (id) => {
|
|
47299
|
+
if (maxDepth !== undefined) {
|
|
47300
|
+
const itemDepth = getItemDepth(items, id);
|
|
47301
|
+
if (itemDepth >= maxDepth - 1) {
|
|
47302
|
+
return;
|
|
47303
|
+
}
|
|
47304
|
+
}
|
|
47293
47305
|
setModalState({
|
|
47294
47306
|
isOpen: true,
|
|
47295
47307
|
mode: "add",
|
|
@@ -47372,6 +47384,21 @@ function findItemDeep2(items, itemId) {
|
|
|
47372
47384
|
}
|
|
47373
47385
|
return;
|
|
47374
47386
|
}
|
|
47387
|
+
function getItemDepth(items, itemId, depth = 0) {
|
|
47388
|
+
for (const item of items) {
|
|
47389
|
+
const { id, children } = item;
|
|
47390
|
+
if (id === itemId) {
|
|
47391
|
+
return depth;
|
|
47392
|
+
}
|
|
47393
|
+
if (children.length) {
|
|
47394
|
+
const childDepth = getItemDepth(children, itemId, depth + 1);
|
|
47395
|
+
if (childDepth !== -1) {
|
|
47396
|
+
return childDepth;
|
|
47397
|
+
}
|
|
47398
|
+
}
|
|
47399
|
+
}
|
|
47400
|
+
return -1;
|
|
47401
|
+
}
|
|
47375
47402
|
// admin/src/fields/DataNested/keyboardCoordinates.ts
|
|
47376
47403
|
var import_core = __toESM(require_dist3(), 1);
|
|
47377
47404
|
|
|
@@ -47544,6 +47571,7 @@ function SortableTree({
|
|
|
47544
47571
|
indicator = false,
|
|
47545
47572
|
indentationWidth = DEFAULT_INDENTATION_WIDTH,
|
|
47546
47573
|
removable,
|
|
47574
|
+
maxDepth,
|
|
47547
47575
|
onChange
|
|
47548
47576
|
}) {
|
|
47549
47577
|
const {
|
|
@@ -47559,7 +47587,7 @@ function SortableTree({
|
|
|
47559
47587
|
handleModalClose,
|
|
47560
47588
|
handleModalSubmit,
|
|
47561
47589
|
getInitialData
|
|
47562
|
-
} = useTreeItems(defaultItems);
|
|
47590
|
+
} = useTreeItems(defaultItems, maxDepth);
|
|
47563
47591
|
const [activeId, setActiveId] = useState7(null);
|
|
47564
47592
|
const flattenedItems = useMemo3(() => {
|
|
47565
47593
|
const flattenedTree = flattenTree(items);
|
|
@@ -47579,7 +47607,7 @@ function SortableTree({
|
|
|
47579
47607
|
handleDragOver,
|
|
47580
47608
|
handleDragCancel
|
|
47581
47609
|
} = useDragState(flattenedItems, setActiveId);
|
|
47582
|
-
const projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth) : null;
|
|
47610
|
+
const projected = activeId && overId ? getProjection(flattenedItems, activeId, overId, offsetLeft, indentationWidth, maxDepth) : null;
|
|
47583
47611
|
const sensorContext = useRef2({
|
|
47584
47612
|
items: flattenedItems,
|
|
47585
47613
|
offset: offsetLeft
|
|
@@ -47659,7 +47687,7 @@ function SortableTree({
|
|
|
47659
47687
|
collapsed: Boolean(collapsed && children.length),
|
|
47660
47688
|
onCollapse: collapsible && children.length ? () => handleCollapse(id) : undefined,
|
|
47661
47689
|
onAddSibling: () => handleAddSibling(id),
|
|
47662
|
-
onAddChild: () => handleAddChild(id),
|
|
47690
|
+
onAddChild: maxDepth !== undefined && depth >= maxDepth - 1 ? undefined : () => handleAddChild(id),
|
|
47663
47691
|
onEdit: () => handleEdit(id),
|
|
47664
47692
|
onRemove: removable ? () => handleRemove(id) : undefined
|
|
47665
47693
|
}, id, false, undefined, this)),
|
|
@@ -47695,7 +47723,8 @@ var DataNested = ({
|
|
|
47695
47723
|
name,
|
|
47696
47724
|
label,
|
|
47697
47725
|
hint,
|
|
47698
|
-
required
|
|
47726
|
+
required,
|
|
47727
|
+
attribute
|
|
47699
47728
|
}) => {
|
|
47700
47729
|
const field = useField2(name);
|
|
47701
47730
|
const handleChange = (value) => {
|
|
@@ -47716,6 +47745,7 @@ var DataNested = ({
|
|
|
47716
47745
|
indicator: true,
|
|
47717
47746
|
removable: true,
|
|
47718
47747
|
defaultItems: field.value || [],
|
|
47748
|
+
maxDepth: attribute.options?.depth,
|
|
47719
47749
|
onChange: handleChange
|
|
47720
47750
|
}, undefined, false, undefined, this),
|
|
47721
47751
|
/* @__PURE__ */ jsxDEV23(Field2.Hint, {}, undefined, false, undefined, this),
|
|
@@ -47753,6 +47783,18 @@ var registerDataNested = (app) => {
|
|
|
47753
47783
|
id: "form.attribute.item.requiredField.description",
|
|
47754
47784
|
defaultMessage: "Cannot create entry if empty"
|
|
47755
47785
|
}
|
|
47786
|
+
},
|
|
47787
|
+
{
|
|
47788
|
+
name: "options.depth",
|
|
47789
|
+
type: "number",
|
|
47790
|
+
intlLabel: {
|
|
47791
|
+
id: `${pluginId}.fields.dataNested.options.depthField.label`,
|
|
47792
|
+
defaultMessage: "Nested max depth"
|
|
47793
|
+
},
|
|
47794
|
+
description: {
|
|
47795
|
+
id: `${pluginId}.fields.dataNested.options.depthField.description`,
|
|
47796
|
+
defaultMessage: "Maximum depth of nested items"
|
|
47797
|
+
}
|
|
47756
47798
|
}
|
|
47757
47799
|
]
|
|
47758
47800
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -86,6 +86,29 @@ var schema_default = {
|
|
|
86
86
|
localized: true
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
},
|
|
90
|
+
socials: {
|
|
91
|
+
type: "component",
|
|
92
|
+
pluginOptions: {
|
|
93
|
+
i18n: {
|
|
94
|
+
localized: true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
component: "site.social",
|
|
98
|
+
repeatable: true
|
|
99
|
+
},
|
|
100
|
+
footLinks: {
|
|
101
|
+
type: "customField",
|
|
102
|
+
pluginOptions: {
|
|
103
|
+
i18n: {
|
|
104
|
+
localized: true
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
customField: "plugin::website.dataNested",
|
|
108
|
+
required: false,
|
|
109
|
+
options: {
|
|
110
|
+
depth: 2
|
|
111
|
+
}
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
114
|
};
|
package/dist/server/index.mjs
CHANGED
|
@@ -51,6 +51,29 @@ var schema_default = {
|
|
|
51
51
|
localized: true
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
},
|
|
55
|
+
socials: {
|
|
56
|
+
type: "component",
|
|
57
|
+
pluginOptions: {
|
|
58
|
+
i18n: {
|
|
59
|
+
localized: true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
component: "site.social",
|
|
63
|
+
repeatable: true
|
|
64
|
+
},
|
|
65
|
+
footLinks: {
|
|
66
|
+
type: "customField",
|
|
67
|
+
pluginOptions: {
|
|
68
|
+
i18n: {
|
|
69
|
+
localized: true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
customField: "plugin::website.dataNested",
|
|
73
|
+
required: false,
|
|
74
|
+
options: {
|
|
75
|
+
depth: 2
|
|
76
|
+
}
|
|
54
77
|
}
|
|
55
78
|
}
|
|
56
79
|
};
|