@limetech/lime-elements 39.13.2 → 39.14.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 +14 -0
- package/dist/cjs/{_assignValue-D2D1zedG.js → _assignValue-DpsLUlF4.js} +25 -2
- package/dist/cjs/{_baseForOwn-QM0kHQT5.js → _baseEach-C570gT5Y.js} +43 -1
- package/dist/cjs/{_baseIsEqual-D6hrjmx4.js → _baseIsEqual-aOPReRWl.js} +1 -0
- package/dist/cjs/{_baseIteratee-iGEZ9pZY.js → _baseIteratee-DggA4e7a.js} +3 -1
- package/dist/cjs/_commonjsHelpers-CFO10eej.js +7 -0
- package/dist/cjs/_getAllKeysIn-BQIV8aw7.js +118 -0
- package/dist/cjs/_isIterateeCall-CPWXFS_s.js +72 -0
- package/dist/cjs/cloneDeep-CxFNKF1Y.js +619 -0
- package/dist/cjs/{isArrayLikeObject-CTP6Ak01.js → difference-Bfsq4sXB.js} +93 -5
- package/dist/cjs/{focus-trigger-element-NnpJ5nTp.js → focus-trigger-element-Brw8VubX.js} +1 -1
- package/dist/cjs/{format-D04vDIBj.js → format-D4jZb7Ls.js} +1 -1
- package/dist/cjs/{index-mbfaT7TB.js → index-BgFEL6FF.js} +1 -1
- package/dist/cjs/{isEmpty-DCC_l2Xp.js → isEmpty-EBCFxX1S.js} +1 -1
- package/dist/cjs/{isEqual-BsHLqE-x.js → isEqual-bXyw7kXo.js} +1 -1
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-badge.cjs.entry.js +2 -2
- package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js +2 -3
- package/dist/cjs/limel-chip_2.cjs.entry.js +3 -3
- package/dist/cjs/limel-circular-progress.cjs.entry.js +2 -2
- package/dist/cjs/limel-code-editor.cjs.entry.js +1 -1
- package/dist/cjs/limel-date-picker.cjs.entry.js +3 -3
- package/dist/cjs/limel-dialog.cjs.entry.js +2 -2
- package/dist/cjs/limel-file-dropzone_2.cjs.entry.js +5 -44
- package/dist/cjs/limel-file-viewer.cjs.entry.js +2 -2
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +12 -74
- package/dist/cjs/limel-form.cjs.entry.js +38541 -50295
- package/dist/cjs/limel-markdown.cjs.entry.js +3 -3
- package/dist/cjs/limel-picker.cjs.entry.js +1 -0
- package/dist/cjs/limel-popover_2.cjs.entry.js +2 -3
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +13 -478
- package/dist/cjs/limel-tab-bar.cjs.entry.js +4 -83
- package/dist/cjs/limel-table.cjs.entry.js +17 -272
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{markdown-parser-DCnW9yak.js → markdown-parser-BIa99LAc.js} +2 -2
- package/dist/cjs/{moment-DCqC7BZP.js → moment-CqRdiK10.js} +1 -1
- package/dist/cjs/pickBy-kLjYLoam.js +201 -0
- package/dist/cjs/{sv-jO-ewmqh.js → sv-BSR4W58y.js} +1 -1
- package/dist/collection/components/form/adapters/widget-adapter.js +23 -30
- package/dist/collection/components/form/fields/array-field.js +39 -6
- package/dist/collection/components/form/fields/field-helpers.js +4 -4
- package/dist/collection/components/form/fields/object-field.js +4 -2
- package/dist/collection/components/form/fields/schema-field.js +33 -70
- package/dist/collection/components/form/form.css +19 -19
- package/dist/collection/components/form/form.js +40 -72
- package/dist/collection/components/form/form.test-schemas.js +308 -0
- package/dist/collection/components/form/row/row-context.js +2 -0
- package/dist/collection/components/form/row/row.js +2 -2
- package/dist/collection/components/form/templates/array-context.js +2 -0
- package/dist/collection/components/form/templates/array-field-collapsible-item.js +4 -4
- package/dist/collection/components/form/templates/array-field-item.js +47 -0
- package/dist/collection/components/form/templates/array-field-simple-item.js +6 -7
- package/dist/collection/components/form/templates/array-field.js +38 -94
- package/dist/collection/components/form/templates/index.js +1 -0
- package/dist/collection/components/form/templates/object-field.js +15 -11
- package/dist/collection/components/form/validation-display.js +75 -0
- package/dist/collection/components/form/validator.js +10 -0
- package/dist/collection/components/form/widgets/code-editor.js +1 -1
- package/dist/collection/components/form/widgets/select.js +2 -1
- package/dist/collection/components/picker/picker.js +1 -0
- package/dist/collection/components/table/table.js +12 -12
- package/dist/esm/{_assignValue-DkGAX8ec.js → _assignValue-DOEO9byf.js} +24 -2
- package/dist/esm/{_baseForOwn-CfpQNnvA.js → _baseEach-CL_-rBMy.js} +42 -2
- package/dist/esm/{_baseIsEqual-BvHnKRmD.js → _baseIsEqual-BfXMsuGh.js} +2 -2
- package/dist/esm/{_baseIteratee-DFBCJcMA.js → _baseIteratee-kS1-0_xD.js} +3 -3
- package/dist/esm/_commonjsHelpers-B85MJLTf.js +5 -0
- package/dist/esm/_getAllKeysIn-BKpeslPJ.js +113 -0
- package/dist/esm/_isIterateeCall-CTcCv8Mb.js +69 -0
- package/dist/esm/cloneDeep-BXAw5H-1.js +609 -0
- package/dist/esm/{isArrayLikeObject-D7yRwRv4.js → difference-DMAjHh-t.js} +91 -7
- package/dist/esm/{focus-trigger-element-6aEStEKM.js → focus-trigger-element-DubROLkE.js} +1 -1
- package/dist/esm/{format-BMPGHLQ8.js → format-hTrthuPP.js} +1 -1
- package/dist/esm/{index-DJJymEnS.js → index-t4DgGbWS.js} +1 -1
- package/dist/esm/{isArrayLike-bWHU4ebg.js → isArrayLike-D1QkaJU2.js} +1 -1
- package/dist/esm/{isEmpty-tfwtR2ai.js → isEmpty-DrFXbHWO.js} +2 -2
- package/dist/esm/{isEqual-BkQ4Z_9r.js → isEqual-CpaoJ_AF.js} +1 -1
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-badge.entry.js +2 -2
- package/dist/esm/limel-breadcrumbs_7.entry.js +2 -3
- package/dist/esm/limel-chip_2.entry.js +4 -4
- package/dist/esm/limel-circular-progress.entry.js +2 -2
- package/dist/esm/limel-code-editor.entry.js +1 -1
- package/dist/esm/limel-date-picker.entry.js +3 -3
- package/dist/esm/limel-dialog.entry.js +3 -3
- package/dist/esm/limel-file-dropzone_2.entry.js +4 -43
- package/dist/esm/limel-file-viewer.entry.js +2 -2
- package/dist/esm/limel-flatpickr-adapter.entry.js +8 -70
- package/dist/esm/limel-form.entry.js +38553 -50307
- package/dist/esm/limel-markdown.entry.js +3 -3
- package/dist/esm/limel-picker.entry.js +1 -0
- package/dist/esm/limel-popover_2.entry.js +2 -3
- package/dist/esm/limel-prosemirror-adapter.entry.js +12 -477
- package/dist/esm/limel-tab-bar.entry.js +4 -83
- package/dist/esm/limel-table.entry.js +14 -269
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{markdown-parser-CXYHPPe2.js → markdown-parser-D7vLKElE.js} +2 -2
- package/dist/esm/{moment-DhvPC9Jt.js → moment-DQRNe8qq.js} +1 -1
- package/dist/esm/pickBy-BEA90LIZ.js +195 -0
- package/dist/esm/{sv-84mf7Xsv.js → sv-CY-6-yEp.js} +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-1cb2d781.entry.js +13 -0
- package/dist/lime-elements/{p-bd77c457.entry.js → p-2160ff6e.entry.js} +1 -1
- package/dist/lime-elements/{p-00d6ccd6.entry.js → p-25ae3a55.entry.js} +5 -5
- package/dist/lime-elements/{p-be0cbddb.entry.js → p-374ec191.entry.js} +1 -1
- package/dist/lime-elements/p-3a662d7e.entry.js +1 -0
- package/dist/lime-elements/{p-f0f5eda1.entry.js → p-41be4893.entry.js} +1 -1
- package/dist/lime-elements/{p-c84911e6.entry.js → p-4ad193a2.entry.js} +1 -1
- package/dist/lime-elements/{p-dd7a2361.entry.js → p-4ce682cf.entry.js} +3 -3
- package/dist/lime-elements/{p-eeae0ef6.entry.js → p-5ee484a7.entry.js} +4 -4
- package/dist/lime-elements/{p-b1d6553c.entry.js → p-77abb595.entry.js} +1 -1
- package/dist/lime-elements/p-8065425a.entry.js +1 -0
- package/dist/lime-elements/{p-77ba0f66.entry.js → p-8299af78.entry.js} +1 -1
- package/dist/lime-elements/{p-87c5e951.entry.js → p-8c7a7003.entry.js} +1 -1
- package/dist/lime-elements/{p-ce20d720.entry.js → p-97c401f1.entry.js} +1 -1
- package/dist/lime-elements/p-9a378cf0.entry.js +1 -0
- package/dist/lime-elements/p-B3zCFNAw.js +1 -0
- package/dist/lime-elements/p-B6bNnxRu.js +1 -0
- package/dist/lime-elements/p-B85MJLTf.js +1 -0
- package/dist/lime-elements/p-BCMRfUKp.js +1 -0
- package/dist/lime-elements/p-BbU4FGNT.js +1 -0
- package/dist/lime-elements/p-Bp0tNo1s.js +1 -0
- package/dist/lime-elements/{p-DpyWBa_Z.js → p-Bt64o80S.js} +1 -1
- package/dist/lime-elements/{p-BqiDn_Sf.js → p-BvDmWgCs.js} +1 -1
- package/dist/lime-elements/p-CMjGNANG.js +1 -0
- package/dist/lime-elements/p-DFWcgJ_i.js +1 -0
- package/dist/lime-elements/{p-B4YDb6f3.js → p-DJvGLFul.js} +1 -1
- package/dist/lime-elements/p-DTXIk0fN.js +1 -0
- package/dist/lime-elements/{p-BgPHaiMH.js → p-D_uMnX5g.js} +1 -1
- package/dist/lime-elements/{p-g3InYy9F.js → p-DdYOzHlg.js} +1 -1
- package/dist/lime-elements/{p-ndpPJpml.js → p-DsDkl4Sy.js} +1 -1
- package/dist/lime-elements/p-UGKt6Ywx.js +1 -0
- package/dist/lime-elements/p-afcf580c.entry.js +16 -0
- package/dist/lime-elements/p-b57b08b6.entry.js +1 -0
- package/dist/lime-elements/p-v6b303K5.js +1 -0
- package/dist/lime-elements/p-xQsJdKrq.js +1 -0
- package/dist/lime-elements/{p-BYx8mudw.js → p-zo6O9LC9.js} +2 -2
- package/dist/types/components/form/adapters/widget-adapter.d.ts +3 -2
- package/dist/types/components/form/fields/array-field.d.ts +11 -19
- package/dist/types/components/form/fields/object-field.d.ts +2 -2
- package/dist/types/components/form/fields/schema-field.d.ts +5 -18
- package/dist/types/components/form/form.d.ts +4 -8
- package/dist/types/components/form/form.test-schemas.d.ts +30 -0
- package/dist/types/components/form/row/row-context.d.ts +2 -0
- package/dist/types/components/form/templates/array-context.d.ts +7 -0
- package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +7 -11
- package/dist/types/components/form/templates/array-field-item.d.ts +6 -0
- package/dist/types/components/form/templates/array-field-simple-item.d.ts +7 -9
- package/dist/types/components/form/templates/array-field.d.ts +7 -8
- package/dist/types/components/form/templates/index.d.ts +1 -0
- package/dist/types/components/form/templates/object-field.d.ts +6 -1
- package/dist/types/components/form/templates/types.d.ts +2 -4
- package/dist/types/components/form/validation-display.d.ts +60 -0
- package/dist/types/components/form/validator.d.ts +6 -0
- package/dist/types/components/form/widgets/code-editor.d.ts +1 -1
- package/dist/types/components/form/widgets/types.d.ts +1 -1
- package/dist/types/components/table/table.d.ts +8 -8
- package/package.json +4 -2
- package/dist/cjs/_baseAssignValue-BJgt6T7z.js +0 -27
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
- package/dist/cjs/_getPrototype-BK9cL-57.js +0 -8
- package/dist/cjs/negate-Bg3SqQh6.js +0 -42
- package/dist/collection/components/form/fields/types.js +0 -1
- package/dist/collection/components/form/schema-cache.js +0 -66
- package/dist/esm/_baseAssignValue-C8Uwn8zr.js +0 -25
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
- package/dist/esm/_getPrototype-jV9gkkJy.js +0 -6
- package/dist/esm/negate-ooVD-6_a.js +0 -40
- package/dist/lime-elements/p-45dfcaf3.entry.js +0 -1
- package/dist/lime-elements/p-5db2d069.entry.js +0 -1
- package/dist/lime-elements/p-9728aa4a.entry.js +0 -1
- package/dist/lime-elements/p-BFTU3MAI.js +0 -1
- package/dist/lime-elements/p-BlJd1RC5.js +0 -1
- package/dist/lime-elements/p-C6SEjICu.js +0 -1
- package/dist/lime-elements/p-CqEHNkif.js +0 -1
- package/dist/lime-elements/p-Cs5T63LB.js +0 -1
- package/dist/lime-elements/p-Cw1B5fXE.js +0 -1
- package/dist/lime-elements/p-DKxusNKT.js +0 -1
- package/dist/lime-elements/p-DrjUjEz3.js +0 -1
- package/dist/lime-elements/p-DzlmgobW.js +0 -1
- package/dist/lime-elements/p-ZcW3uvZL.js +0 -1
- package/dist/lime-elements/p-a4a09ce9.entry.js +0 -7
- package/dist/lime-elements/p-ad9cb573.entry.js +0 -1
- package/dist/lime-elements/p-c4e2885d.entry.js +0 -16
- package/dist/lime-elements/p-ooVD-6_a.js +0 -1
- package/dist/types/components/form/fields/types.d.ts +0 -41
- package/dist/types/components/form/schema-cache.d.ts +0 -17
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { isObjectType } from "../schema";
|
|
3
|
+
import { CollapsibleItemTemplate } from "./array-field-collapsible-item";
|
|
4
|
+
import { SimpleItemTemplate } from "./array-field-simple-item";
|
|
5
|
+
import { ArrayFieldContext } from "./array-context";
|
|
6
|
+
export const ArrayFieldItemTemplate = (props) => {
|
|
7
|
+
const arrayContext = useContext(ArrayFieldContext);
|
|
8
|
+
const schema = arrayContext === null || arrayContext === void 0 ? void 0 : arrayContext.arraySchema;
|
|
9
|
+
const formData = arrayContext === null || arrayContext === void 0 ? void 0 : arrayContext.formData;
|
|
10
|
+
const formContext = props.registry.formContext;
|
|
11
|
+
const allowItemReorder = canItemReorder(props, schema);
|
|
12
|
+
const allowItemRemoval = canRemoveItems(schema);
|
|
13
|
+
if (schema && isObjectType(schema.items)) {
|
|
14
|
+
const itemData = Array.isArray(formData)
|
|
15
|
+
? formData[props.index]
|
|
16
|
+
: undefined;
|
|
17
|
+
return React.createElement(CollapsibleItemTemplate, {
|
|
18
|
+
key: props.itemKey,
|
|
19
|
+
buttonsProps: props.buttonsProps,
|
|
20
|
+
index: props.index,
|
|
21
|
+
data: itemData,
|
|
22
|
+
schema: schema,
|
|
23
|
+
formSchema: formContext === null || formContext === void 0 ? void 0 : formContext.schema,
|
|
24
|
+
allowItemRemoval: allowItemRemoval,
|
|
25
|
+
allowItemReorder: allowItemReorder,
|
|
26
|
+
}, props.children);
|
|
27
|
+
}
|
|
28
|
+
return React.createElement(SimpleItemTemplate, {
|
|
29
|
+
key: props.itemKey,
|
|
30
|
+
buttonsProps: props.buttonsProps,
|
|
31
|
+
index: props.index,
|
|
32
|
+
allowItemRemoval: allowItemRemoval,
|
|
33
|
+
allowItemReorder: allowItemReorder,
|
|
34
|
+
}, props.children);
|
|
35
|
+
};
|
|
36
|
+
function canRemoveItems(schema) {
|
|
37
|
+
const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
|
|
38
|
+
return limeOptions.allowItemRemoval !== false;
|
|
39
|
+
}
|
|
40
|
+
function canItemReorder(props, schema) {
|
|
41
|
+
const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
|
|
42
|
+
if (limeOptions.allowItemReorder === false) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const { buttonsProps } = props;
|
|
46
|
+
return Boolean((buttonsProps === null || buttonsProps === void 0 ? void 0 : buttonsProps.hasMoveDown) || (buttonsProps === null || buttonsProps === void 0 ? void 0 : buttonsProps.hasMoveUp));
|
|
47
|
+
}
|
|
@@ -5,8 +5,7 @@ export class SimpleItemTemplate extends React.Component {
|
|
|
5
5
|
super(props);
|
|
6
6
|
this.props = props;
|
|
7
7
|
this.handleRemove = (event) => {
|
|
8
|
-
|
|
9
|
-
item.onDropIndexClick(index)(event);
|
|
8
|
+
this.props.buttonsProps.onRemoveItem(event);
|
|
10
9
|
};
|
|
11
10
|
this.setRemoveButton = (button) => {
|
|
12
11
|
if (this.removeButton) {
|
|
@@ -22,12 +21,12 @@ export class SimpleItemTemplate extends React.Component {
|
|
|
22
21
|
this.setRemoveButton(undefined);
|
|
23
22
|
}
|
|
24
23
|
render() {
|
|
25
|
-
const {
|
|
24
|
+
const { allowItemReorder } = this.props;
|
|
26
25
|
return React.createElement('div', {
|
|
27
26
|
className: 'array-item limel-form-array-item--simple',
|
|
28
|
-
'data-reorder-id': String(this.props.
|
|
27
|
+
'data-reorder-id': String(this.props.index),
|
|
29
28
|
'data-reorderable': allowItemReorder ? 'true' : 'false',
|
|
30
|
-
}, this.props.
|
|
29
|
+
}, this.props.children, this.renderRemoveButton(), this.renderDragHandle());
|
|
31
30
|
}
|
|
32
31
|
renderDragHandle() {
|
|
33
32
|
if (!this.props.allowItemReorder) {
|
|
@@ -37,13 +36,13 @@ export class SimpleItemTemplate extends React.Component {
|
|
|
37
36
|
class: 'drag-handle',
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
|
-
renderRemoveButton(
|
|
39
|
+
renderRemoveButton() {
|
|
41
40
|
if (!this.props.allowItemRemoval) {
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
44
43
|
const props = {
|
|
45
44
|
icon: 'trash',
|
|
46
|
-
disabled: !
|
|
45
|
+
disabled: !this.props.buttonsProps.hasRemove,
|
|
47
46
|
ref: this.setRemoveButton,
|
|
48
47
|
};
|
|
49
48
|
return React.createElement(LIMEL_ICON_BUTTON, props);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { isObjectType } from "../schema";
|
|
3
|
-
import { CollapsibleItemTemplate } from "./array-field-collapsible-item";
|
|
4
|
-
import { SimpleItemTemplate } from "./array-field-simple-item";
|
|
5
2
|
import { renderDescription, renderTitle } from "./common";
|
|
6
3
|
import Sortable from "sortablejs";
|
|
4
|
+
import { ArrayFieldContext } from "./array-context";
|
|
5
|
+
export const ARRAY_REORDER_EVENT = 'arrayReorder';
|
|
7
6
|
const DRAG_HANDLE_SELECTOR = '[data-drag-handle]';
|
|
8
7
|
const DRAGGABLE_ITEM_SELECTOR = '.array-item[data-reorderable="true"]';
|
|
9
8
|
const DEFAULT_CONTAINER_CLASS = 'has-an-item-which-is-being-dragged';
|
|
@@ -13,7 +12,7 @@ const TOUCH_DRAG_DELAY_MS = 200; // Adds a short hold on touch (long-press) so s
|
|
|
13
12
|
export class ArrayFieldTemplate extends React.Component {
|
|
14
13
|
constructor(props) {
|
|
15
14
|
super(props);
|
|
16
|
-
this.
|
|
15
|
+
this.cachedContextValue = null;
|
|
17
16
|
this.handleAddClick = (event) => {
|
|
18
17
|
event.stopPropagation();
|
|
19
18
|
this.props.onAddClick(event);
|
|
@@ -72,20 +71,10 @@ export class ArrayFieldTemplate extends React.Component {
|
|
|
72
71
|
this.scheduleDropElevationRemoval();
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
if (!targetItem || typeof targetItem.onReorderClick !== 'function') {
|
|
80
|
-
this.scheduleDropElevationRemoval();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
requestAnimationFrame(() => {
|
|
84
|
-
const reorder = targetItem.onReorderClick(draggedItemIndex, toPosition);
|
|
85
|
-
if (typeof reorder === 'function') {
|
|
86
|
-
reorder();
|
|
87
|
-
}
|
|
88
|
-
});
|
|
74
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent(ARRAY_REORDER_EVENT, {
|
|
75
|
+
bubbles: true,
|
|
76
|
+
detail: { fromIndex: fromPosition, toIndex: toPosition },
|
|
77
|
+
}));
|
|
89
78
|
this.scheduleDropElevationRemoval();
|
|
90
79
|
};
|
|
91
80
|
this.state = {
|
|
@@ -118,13 +107,12 @@ export class ArrayFieldTemplate extends React.Component {
|
|
|
118
107
|
}
|
|
119
108
|
}
|
|
120
109
|
render() {
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
this.
|
|
124
|
-
return React.createElement('div', {}, renderTitle(this.props.title), renderDescription(this.props.schema.description), React.createElement('div', {
|
|
110
|
+
const orderedItems = this.getOrderedItems();
|
|
111
|
+
const contextValue = this.getContextValue();
|
|
112
|
+
return React.createElement(ArrayFieldContext.Provider, { value: contextValue }, React.createElement('div', {}, renderTitle(this.props.title), renderDescription(this.props.schema.description), React.createElement('div', {
|
|
125
113
|
className: 'array-items',
|
|
126
114
|
ref: this.setContainer,
|
|
127
|
-
}, orderedItems
|
|
115
|
+
}, orderedItems), this.renderAddButton()));
|
|
128
116
|
}
|
|
129
117
|
renderAddButton() {
|
|
130
118
|
if (!this.props.canAdd) {
|
|
@@ -137,73 +125,40 @@ export class ArrayFieldTemplate extends React.Component {
|
|
|
137
125
|
class: 'button-add-new',
|
|
138
126
|
});
|
|
139
127
|
}
|
|
140
|
-
getItemControls() {
|
|
141
|
-
return {
|
|
142
|
-
allowItemRemoval: this.canRemoveItems(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
renderItem(item, index, controls) {
|
|
146
|
-
var _a;
|
|
147
|
-
const { schema, formData, formContext } = this.props;
|
|
148
|
-
const itemIndex = (_a = item.index) !== null && _a !== void 0 ? _a : index;
|
|
149
|
-
const allowItemReorder = this.isItemReorderable(item);
|
|
150
|
-
if (isObjectType(schema.items)) {
|
|
151
|
-
return React.createElement(CollapsibleItemTemplate, {
|
|
152
|
-
key: item.key,
|
|
153
|
-
item: item,
|
|
154
|
-
data: Array.isArray(formData) ? formData[itemIndex] : undefined,
|
|
155
|
-
schema: schema,
|
|
156
|
-
formSchema: formContext.schema,
|
|
157
|
-
index: itemIndex,
|
|
158
|
-
allowItemRemoval: controls.allowItemRemoval,
|
|
159
|
-
allowItemReorder: allowItemReorder,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
return React.createElement(SimpleItemTemplate, {
|
|
163
|
-
key: item.key,
|
|
164
|
-
item: item,
|
|
165
|
-
index: itemIndex,
|
|
166
|
-
dataIndex: itemIndex,
|
|
167
|
-
allowItemRemoval: controls.allowItemRemoval,
|
|
168
|
-
allowItemReorder: allowItemReorder,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
128
|
getOrderedItems() {
|
|
172
|
-
var _a
|
|
129
|
+
var _a;
|
|
173
130
|
const items = (_a = this.props.items) !== null && _a !== void 0 ? _a : [];
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
131
|
+
if (items.length === 0) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const byKey = new Map();
|
|
135
|
+
for (const [index, item] of items.entries()) {
|
|
136
|
+
byKey.set(index, item);
|
|
179
137
|
}
|
|
180
138
|
const ordered = [];
|
|
181
139
|
const used = new Set();
|
|
182
140
|
for (const index of this.state.order) {
|
|
183
|
-
const entry =
|
|
141
|
+
const entry = byKey.get(index);
|
|
184
142
|
if (!entry) {
|
|
185
143
|
continue;
|
|
186
144
|
}
|
|
187
145
|
ordered.push(entry);
|
|
188
146
|
used.add(index);
|
|
189
147
|
}
|
|
190
|
-
for (const [index, entry] of
|
|
148
|
+
for (const [index, entry] of byKey.entries()) {
|
|
191
149
|
if (!used.has(index)) {
|
|
192
150
|
ordered.push(entry);
|
|
193
151
|
}
|
|
194
152
|
}
|
|
195
|
-
return
|
|
196
|
-
ordered,
|
|
197
|
-
byIndex,
|
|
198
|
-
};
|
|
153
|
+
return ordered;
|
|
199
154
|
}
|
|
200
155
|
setupDragController() {
|
|
201
156
|
if (!this.container || !this.canReorderItems()) {
|
|
202
157
|
this.teardownDragController();
|
|
203
158
|
return;
|
|
204
159
|
}
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
160
|
+
const reorderableItems = this.container.querySelectorAll(`:scope > ${DRAGGABLE_ITEM_SELECTOR}`);
|
|
161
|
+
if (reorderableItems.length < 2) {
|
|
207
162
|
this.teardownDragController();
|
|
208
163
|
return;
|
|
209
164
|
}
|
|
@@ -249,31 +204,6 @@ export class ArrayFieldTemplate extends React.Component {
|
|
|
249
204
|
const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
|
|
250
205
|
return limeOptions.allowItemReorder !== false;
|
|
251
206
|
}
|
|
252
|
-
canRemoveItems() {
|
|
253
|
-
const schema = this.props.schema;
|
|
254
|
-
const limeOptions = (schema === null || schema === void 0 ? void 0 : schema.lime) || {};
|
|
255
|
-
return limeOptions.allowItemRemoval !== false;
|
|
256
|
-
}
|
|
257
|
-
isItemReorderable(item) {
|
|
258
|
-
return (this.canReorderItems() &&
|
|
259
|
-
Boolean((item === null || item === void 0 ? void 0 : item.hasMoveDown) || (item === null || item === void 0 ? void 0 : item.hasMoveUp)));
|
|
260
|
-
}
|
|
261
|
-
isIndexReorderable(index) {
|
|
262
|
-
const item = this.itemByIndex.get(index);
|
|
263
|
-
if (!item) {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
return this.isItemReorderable(item);
|
|
267
|
-
}
|
|
268
|
-
getReorderableOrder(order = this.state.order) {
|
|
269
|
-
const result = [];
|
|
270
|
-
for (const index of order) {
|
|
271
|
-
if (this.isIndexReorderable(index)) {
|
|
272
|
-
result.push(index);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return result;
|
|
276
|
-
}
|
|
277
207
|
readOrderFromDom() {
|
|
278
208
|
if (!this.container) {
|
|
279
209
|
return [];
|
|
@@ -348,6 +278,20 @@ export class ArrayFieldTemplate extends React.Component {
|
|
|
348
278
|
return true;
|
|
349
279
|
}
|
|
350
280
|
extractIndices(items = []) {
|
|
351
|
-
return (items !== null && items !== void 0 ? items : []).map((
|
|
281
|
+
return (items !== null && items !== void 0 ? items : []).map((_, index) => index);
|
|
282
|
+
}
|
|
283
|
+
getContextValue() {
|
|
284
|
+
var _a;
|
|
285
|
+
const schema = this.props.schema;
|
|
286
|
+
const formData = ((_a = this.props.formData) !== null && _a !== void 0 ? _a : []);
|
|
287
|
+
if (this.cachedContextValue &&
|
|
288
|
+
this.cachedSchema === schema &&
|
|
289
|
+
this.cachedFormData === formData) {
|
|
290
|
+
return this.cachedContextValue;
|
|
291
|
+
}
|
|
292
|
+
this.cachedSchema = schema;
|
|
293
|
+
this.cachedFormData = formData;
|
|
294
|
+
this.cachedContextValue = { arraySchema: schema, formData };
|
|
295
|
+
return this.cachedContextValue;
|
|
352
296
|
}
|
|
353
297
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
2
|
import { renderDescription, renderTitle } from "./common";
|
|
3
3
|
import { GridLayout } from "./grid-layout";
|
|
4
4
|
import { RowLayout } from "./row-layout";
|
|
5
5
|
import { getHelpComponent } from "../help";
|
|
6
|
+
import { ArrayFieldContext } from "./array-context";
|
|
6
7
|
export const ObjectFieldTemplate = (props) => {
|
|
7
|
-
const
|
|
8
|
+
const arrayContext = useContext(ArrayFieldContext);
|
|
9
|
+
const id = props.fieldPathId.$id;
|
|
10
|
+
if (arrayContext && id !== 'root') {
|
|
11
|
+
return React.createElement(ArrayFieldContext.Provider, { value: null }, renderProperties(props.properties, props.schema));
|
|
12
|
+
}
|
|
8
13
|
if (id === 'root' || !isCollapsible(props.schema)) {
|
|
9
14
|
return renderFieldWithTitle(props);
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
return renderCollapsibleField(props);
|
|
13
|
-
}
|
|
14
|
-
return renderProperties(props.properties, props.schema);
|
|
16
|
+
return renderCollapsibleField(props);
|
|
15
17
|
};
|
|
16
18
|
function renderFieldWithTitle(props) {
|
|
17
19
|
return React.createElement(React.Fragment, {}, renderSectionHeader(props), renderDescription(props.description), renderProperties(props.properties, props.schema));
|
|
@@ -30,17 +32,19 @@ function renderCollapsibleField(props) {
|
|
|
30
32
|
});
|
|
31
33
|
return React.createElement('limel-collapsible-section', {
|
|
32
34
|
header: props.title,
|
|
33
|
-
id: getSchemaObjectPropertyPath(props.formContext.schema, props.
|
|
35
|
+
id: getSchemaObjectPropertyPath(props.registry.formContext.schema, props.fieldPathId),
|
|
34
36
|
'is-open': defaultOpen,
|
|
35
37
|
}, helpElement, renderDescription(props.description), renderProperties(props.properties, props.schema));
|
|
36
38
|
}
|
|
37
|
-
function getSchemaObjectPropertyPath(schema,
|
|
39
|
+
function getSchemaObjectPropertyPath(schema, fieldPathId) {
|
|
38
40
|
var _a, _b;
|
|
39
41
|
const refPrefixLength = 2;
|
|
40
42
|
const matchAllForwardSlashes = /\//g;
|
|
41
|
-
const rootPath = (_a = schema.$ref) === null || _a === void 0 ? void 0 : _a.replace(matchAllForwardSlashes, '.').slice(refPrefixLength);
|
|
42
|
-
const subSchemaPath =
|
|
43
|
-
|
|
43
|
+
const rootPath = (_b = (_a = schema.$ref) === null || _a === void 0 ? void 0 : _a.replace(matchAllForwardSlashes, '.').slice(refPrefixLength)) !== null && _b !== void 0 ? _b : '';
|
|
44
|
+
const subSchemaPath = fieldPathId.path
|
|
45
|
+
.map((segment) => `.properties.${segment}`)
|
|
46
|
+
.join('');
|
|
47
|
+
return `${rootPath}${subSchemaPath}`;
|
|
44
48
|
}
|
|
45
49
|
function renderProperties(properties, schema) {
|
|
46
50
|
var _a;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isEmpty, capitalize } from "lodash-es";
|
|
2
|
+
/**
|
|
3
|
+
* Check whether a form field value is non-empty.
|
|
4
|
+
* Treats `null`, `undefined`, `''`, empty arrays,
|
|
5
|
+
* and empty plain objects as "no value".
|
|
6
|
+
*
|
|
7
|
+
* @param value - the current field value
|
|
8
|
+
* @returns `true` when the field holds meaningful data
|
|
9
|
+
*/
|
|
10
|
+
export function hasValue(value) {
|
|
11
|
+
if (value === null || value === undefined || value === '') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.length > 0;
|
|
16
|
+
}
|
|
17
|
+
if (value instanceof Date) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'object') {
|
|
21
|
+
return !isEmpty(value);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Determine whether a field should be displayed as invalid.
|
|
27
|
+
*
|
|
28
|
+
* A field with errors is shown as invalid only when the user has
|
|
29
|
+
* interacted with it, it already contains a value, or it is optional.
|
|
30
|
+
* This avoids showing errors on untouched required fields before the
|
|
31
|
+
* user has had a chance to fill them in.
|
|
32
|
+
*
|
|
33
|
+
* @param field - the current field state
|
|
34
|
+
* @param field.hasErrors - whether the field currently has validation errors
|
|
35
|
+
* @param field.modified - whether the user has interacted with the field
|
|
36
|
+
* @param field.hasValue - whether the field holds a non-empty value
|
|
37
|
+
* @param field.required - whether the field is required
|
|
38
|
+
* @returns `true` when the field should render in an invalid state
|
|
39
|
+
*/
|
|
40
|
+
export function isFieldInvalid(field) {
|
|
41
|
+
return (field.hasErrors && (field.modified || field.hasValue || !field.required));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check whether a field should be marked as required.
|
|
45
|
+
*
|
|
46
|
+
* A field is required when the schema marks it as `required` or
|
|
47
|
+
* when it specifies a positive `minItems` constraint.
|
|
48
|
+
*
|
|
49
|
+
* @param field - the current field state
|
|
50
|
+
* @param field.required - the `required` flag from the schema/props
|
|
51
|
+
* @param field.minItems - the `minItems` value from the schema (0 if unset)
|
|
52
|
+
* @returns `true` when the field is required
|
|
53
|
+
*/
|
|
54
|
+
export function isFieldRequired(field) {
|
|
55
|
+
return field.required || field.minItems > 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Return the helper text to display beneath a field.
|
|
59
|
+
*
|
|
60
|
+
* When validation errors exist the first error message is returned
|
|
61
|
+
* (capitalized). Otherwise falls back to `fallbackText` if provided,
|
|
62
|
+
* then to `description`.
|
|
63
|
+
*
|
|
64
|
+
* @param errors - array of validation error strings (may be `null`)
|
|
65
|
+
* @param description - the schema description for the field
|
|
66
|
+
* @param fallbackText - optional text that takes priority over `description`
|
|
67
|
+
* when there are no errors (e.g. a custom `helperText` prop)
|
|
68
|
+
* @returns the string to show as helper text
|
|
69
|
+
*/
|
|
70
|
+
export function getErrorText(errors, description, fallbackText) {
|
|
71
|
+
if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
|
|
72
|
+
return capitalize(errors[0]);
|
|
73
|
+
}
|
|
74
|
+
return fallbackText || description;
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { customizeValidator } from "@rjsf/validator-ajv8";
|
|
2
|
+
import { isInteger } from "./validators";
|
|
3
|
+
/**
|
|
4
|
+
* Shared RJSF validator configured with custom formats and ajv options.
|
|
5
|
+
* Use this single instance wherever the RJSF v6 API requires a validator.
|
|
6
|
+
*/
|
|
7
|
+
export const rjsfValidator = customizeValidator({
|
|
8
|
+
customFormats: { integer: isInteger },
|
|
9
|
+
ajvOptionsOverrides: { allErrors: true, multipleOfPrecision: 2 },
|
|
10
|
+
});
|
|
@@ -62,7 +62,7 @@ export class CodeEditor extends React.Component {
|
|
|
62
62
|
this.setState({ validationError, modified: true });
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
props.onChange(value);
|
|
65
|
+
props.onChange(value, props.fieldPathId.path);
|
|
66
66
|
this.setState({ validationError: '', modified: true });
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -48,10 +48,11 @@ export class Select extends React.Component {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
function createOption(item) {
|
|
51
|
+
var _a;
|
|
51
52
|
return {
|
|
52
53
|
text: item.label,
|
|
53
54
|
value: item.value,
|
|
54
|
-
disabled: !!item.schema.readOnly,
|
|
55
|
+
disabled: !!((_a = item.schema) === null || _a === void 0 ? void 0 : _a.readOnly),
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
function findValue(value, options) {
|
|
@@ -612,16 +612,16 @@ export class Table {
|
|
|
612
612
|
render() {
|
|
613
613
|
var _a, _b;
|
|
614
614
|
const totalRows = (_a = this.totalRows) !== null && _a !== void 0 ? _a : this.data.length;
|
|
615
|
-
return (h(Host, { key: '
|
|
615
|
+
return (h(Host, { key: '68ff4552c148835bc927f9ce5587e8073c2cbf3d', class: {
|
|
616
616
|
'has-low-density': this.layout === 'lowDensity',
|
|
617
617
|
'has-pagination-on-top': this.paginationLocation === 'top',
|
|
618
|
-
} }, h("div", { key: '
|
|
618
|
+
} }, h("div", { key: '3a7cf6c12e83db4b17f2bffdad17c113c7c7ca45', id: "tabulator-container", class: {
|
|
619
619
|
'has-pagination': totalRows > this.pageSize,
|
|
620
620
|
'has-aggregation': this.hasAggregation(this.columns),
|
|
621
621
|
'has-movable-columns': this.movableColumns,
|
|
622
622
|
'has-rowselector': this.selectable,
|
|
623
623
|
'has-selection': (_b = this.tableSelection) === null || _b === void 0 ? void 0 : _b.hasSelection,
|
|
624
|
-
} }, h("div", { key: '
|
|
624
|
+
} }, h("div", { key: '1aeea14d08105a4fbc95d238122ce9f4574a296b', id: "tabulator-loader", style: { display: this.loading ? 'flex' : 'none' } }, h("limel-spinner", { key: '496c560a362f469616a23801902d9a748b1293ad', size: "large" })), this.renderEmptyMessage(), this.renderSelectAll(), h("div", { key: '1b9e129b2e30b6c8c9256f612dc4cd9fa53b3afc', id: "tabulator-table" }))));
|
|
625
625
|
}
|
|
626
626
|
renderSelectAll() {
|
|
627
627
|
var _a, _b, _c;
|
|
@@ -709,7 +709,7 @@ export class Table {
|
|
|
709
709
|
},
|
|
710
710
|
"getter": false,
|
|
711
711
|
"setter": false,
|
|
712
|
-
"reflect":
|
|
712
|
+
"reflect": true,
|
|
713
713
|
"attribute": "mode",
|
|
714
714
|
"defaultValue": "'local'"
|
|
715
715
|
},
|
|
@@ -736,7 +736,7 @@ export class Table {
|
|
|
736
736
|
},
|
|
737
737
|
"getter": false,
|
|
738
738
|
"setter": false,
|
|
739
|
-
"reflect":
|
|
739
|
+
"reflect": true,
|
|
740
740
|
"attribute": "layout"
|
|
741
741
|
},
|
|
742
742
|
"pageSize": {
|
|
@@ -755,7 +755,7 @@ export class Table {
|
|
|
755
755
|
},
|
|
756
756
|
"getter": false,
|
|
757
757
|
"setter": false,
|
|
758
|
-
"reflect":
|
|
758
|
+
"reflect": true,
|
|
759
759
|
"attribute": "page-size"
|
|
760
760
|
},
|
|
761
761
|
"totalRows": {
|
|
@@ -774,7 +774,7 @@ export class Table {
|
|
|
774
774
|
},
|
|
775
775
|
"getter": false,
|
|
776
776
|
"setter": false,
|
|
777
|
-
"reflect":
|
|
777
|
+
"reflect": true,
|
|
778
778
|
"attribute": "total-rows"
|
|
779
779
|
},
|
|
780
780
|
"sorting": {
|
|
@@ -842,7 +842,7 @@ export class Table {
|
|
|
842
842
|
},
|
|
843
843
|
"getter": false,
|
|
844
844
|
"setter": false,
|
|
845
|
-
"reflect":
|
|
845
|
+
"reflect": true,
|
|
846
846
|
"attribute": "movable-columns"
|
|
847
847
|
},
|
|
848
848
|
"sortableColumns": {
|
|
@@ -861,7 +861,7 @@ export class Table {
|
|
|
861
861
|
},
|
|
862
862
|
"getter": false,
|
|
863
863
|
"setter": false,
|
|
864
|
-
"reflect":
|
|
864
|
+
"reflect": true,
|
|
865
865
|
"attribute": "sortable-columns",
|
|
866
866
|
"defaultValue": "true"
|
|
867
867
|
},
|
|
@@ -881,7 +881,7 @@ export class Table {
|
|
|
881
881
|
},
|
|
882
882
|
"getter": false,
|
|
883
883
|
"setter": false,
|
|
884
|
-
"reflect":
|
|
884
|
+
"reflect": true,
|
|
885
885
|
"attribute": "loading",
|
|
886
886
|
"defaultValue": "false"
|
|
887
887
|
},
|
|
@@ -901,7 +901,7 @@ export class Table {
|
|
|
901
901
|
},
|
|
902
902
|
"getter": false,
|
|
903
903
|
"setter": false,
|
|
904
|
-
"reflect":
|
|
904
|
+
"reflect": true,
|
|
905
905
|
"attribute": "page",
|
|
906
906
|
"defaultValue": "FIRST_PAGE"
|
|
907
907
|
},
|
|
@@ -964,7 +964,7 @@ export class Table {
|
|
|
964
964
|
},
|
|
965
965
|
"getter": false,
|
|
966
966
|
"setter": false,
|
|
967
|
-
"reflect":
|
|
967
|
+
"reflect": true,
|
|
968
968
|
"attribute": "selectable"
|
|
969
969
|
},
|
|
970
970
|
"selection": {
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as defineProperty } from './_defineProperty-yVdnnt__.js';
|
|
2
2
|
import { e as eq } from './eq-D7VMHFyO.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The base implementation of `assignValue` and `assignMergeValue` without
|
|
6
|
+
* value checks.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
* @param {Object} object The object to modify.
|
|
10
|
+
* @param {string} key The key of the property to assign.
|
|
11
|
+
* @param {*} value The value to assign.
|
|
12
|
+
*/
|
|
13
|
+
function baseAssignValue(object, key, value) {
|
|
14
|
+
if (key == '__proto__' && defineProperty) {
|
|
15
|
+
defineProperty(object, key, {
|
|
16
|
+
'configurable': true,
|
|
17
|
+
'enumerable': true,
|
|
18
|
+
'value': value,
|
|
19
|
+
'writable': true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
object[key] = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
/** Used for built-in method references. */
|
|
5
27
|
var objectProto = Object.prototype;
|
|
6
28
|
|
|
@@ -25,4 +47,4 @@ function assignValue(object, key, value) {
|
|
|
25
47
|
}
|
|
26
48
|
}
|
|
27
49
|
|
|
28
|
-
export { assignValue as a };
|
|
50
|
+
export { assignValue as a, baseAssignValue as b };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { k as keys } from './_baseIsEqual-
|
|
1
|
+
import { k as keys } from './_baseIsEqual-BfXMsuGh.js';
|
|
2
|
+
import { i as isArrayLike } from './isArrayLike-D1QkaJU2.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
|
|
@@ -49,4 +50,43 @@ function baseForOwn(object, iteratee) {
|
|
|
49
50
|
return object && baseFor(object, iteratee, keys);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Creates a `baseEach` or `baseEachRight` function.
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @param {Function} eachFunc The function to iterate over a collection.
|
|
58
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
59
|
+
* @returns {Function} Returns the new base function.
|
|
60
|
+
*/
|
|
61
|
+
function createBaseEach(eachFunc, fromRight) {
|
|
62
|
+
return function(collection, iteratee) {
|
|
63
|
+
if (collection == null) {
|
|
64
|
+
return collection;
|
|
65
|
+
}
|
|
66
|
+
if (!isArrayLike(collection)) {
|
|
67
|
+
return eachFunc(collection, iteratee);
|
|
68
|
+
}
|
|
69
|
+
var length = collection.length,
|
|
70
|
+
index = -1,
|
|
71
|
+
iterable = Object(collection);
|
|
72
|
+
|
|
73
|
+
while ((++index < length)) {
|
|
74
|
+
if (iteratee(iterable[index], index, iterable) === false) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return collection;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The base implementation of `_.forEach` without support for iteratee shorthands.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
87
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
88
|
+
* @returns {Array|Object} Returns `collection`.
|
|
89
|
+
*/
|
|
90
|
+
var baseEach = createBaseEach(baseForOwn);
|
|
91
|
+
|
|
92
|
+
export { baseEach as a, baseFor as b, baseForOwn as c };
|