@deckstar/react-final-form-arrays
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "@deckstar/react-final-form-arrays", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A component for rendering and editing arrays 🏁 React Final Form", | ||
@@ -5,0 +5,0 @@ "main": "dist/src", |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const defaultIsEqual = (aArray, bArray) => aArray === bArray || | ||
@@ -8,2 +6,2 @@ (Array.isArray(aArray) && | ||
!aArray.some((a, index) => a !== bArray[index])); | ||
exports.default = defaultIsEqual; | ||
export default defaultIsEqual; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -13,11 +12,7 @@ var t = {}; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const renderComponent_1 = __importDefault(require("./renderComponent")); | ||
const useFieldArray_1 = __importDefault(require("./useFieldArray")); | ||
import renderComponent from "./renderComponent"; | ||
import useFieldArray from "./useFieldArray"; | ||
const FieldArray = (_a) => { | ||
var { name, subscription, defaultValue, initialValue, isEqual, validate } = _a, rest = __rest(_a, ["name", "subscription", "defaultValue", "initialValue", "isEqual", "validate"]); | ||
const { fields, meta } = (0, useFieldArray_1.default)(name, { | ||
const { fields, meta } = useFieldArray(name, { | ||
subscription, | ||
@@ -29,5 +24,5 @@ defaultValue, | ||
}); | ||
return (0, renderComponent_1.default)(Object.assign({ fields, | ||
return renderComponent(Object.assign({ fields, | ||
meta }, rest), `FieldArray(${name})`); | ||
}; | ||
exports.default = FieldArray; | ||
export default FieldArray; |
@@ -1,10 +0,2 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useFieldArray = exports.FieldArray = void 0; | ||
var FieldArray_1 = require("./FieldArray"); | ||
Object.defineProperty(exports, "FieldArray", { enumerable: true, get: function () { return __importDefault(FieldArray_1).default; } }); | ||
var useFieldArray_1 = require("./useFieldArray"); | ||
Object.defineProperty(exports, "useFieldArray", { enumerable: true, get: function () { return __importDefault(useFieldArray_1).default; } }); | ||
export { default as FieldArray } from "./FieldArray"; | ||
export { default as useFieldArray } from "./useFieldArray"; |
@@ -1,25 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -36,4 +12,3 @@ var t = {}; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const React = __importStar(require("react")); | ||
import * as React from "react"; | ||
// shared logic between components that use either render prop, | ||
@@ -57,2 +32,2 @@ // children render function, or component prop | ||
} | ||
exports.default = renderComponent; | ||
export default renderComponent; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; |
@@ -1,7 +0,2 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importDefault(require("react")); | ||
import React from "react"; | ||
/** | ||
@@ -20,3 +15,3 @@ * A simple hook to create a constant value that lives for | ||
function useConstant(init) { | ||
const ref = react_1.default.useRef(); | ||
const ref = React.useRef(); | ||
if (!ref.current) { | ||
@@ -27,2 +22,2 @@ ref.current = init(); | ||
} | ||
exports.default = useConstant; | ||
export default useConstant; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -13,13 +12,9 @@ var t = {}; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const final_form_1 = require("final-form"); | ||
const react_1 = require("react"); | ||
const react_final_form_1 = require("react-final-form"); | ||
const defaultIsEqual_1 = __importDefault(require("./defaultIsEqual")); | ||
const useConstant_1 = __importDefault(require("./useConstant")); | ||
const useFieldArray = (name, { subscription = react_final_form_1.fullFieldSubscription, defaultValue, initialValue, isEqual = defaultIsEqual_1.default, validate: validateProp, } = {}) => { | ||
const form = (0, react_final_form_1.useForm)("useFieldArray"); | ||
import { ARRAY_ERROR } from "final-form"; | ||
import { useMemo } from "react"; | ||
import { fullFieldSubscription as all, useField, useForm, } from "react-final-form"; | ||
import defaultIsEqual from "./defaultIsEqual"; | ||
import useConstant from "./useConstant"; | ||
const useFieldArray = (name, { subscription = all, defaultValue, initialValue, isEqual = defaultIsEqual, validate: validateProp, } = {}) => { | ||
const form = useForm("useFieldArray"); | ||
const formMutators = form.mutators; | ||
@@ -31,3 +26,3 @@ // @ts-expect-error | ||
} | ||
const mutators = (0, react_1.useMemo)(() => | ||
const mutators = useMemo(() => | ||
// curry the field name onto all mutator calls | ||
@@ -41,3 +36,3 @@ Object.keys(formMutators).reduce((result, _key) => { | ||
}, {}), [name, formMutators]); | ||
const validate = (0, useConstant_1.default)(() => (value, allValues, meta) => { | ||
const validate = useConstant(() => (value, allValues, meta) => { | ||
if (!validateProp) | ||
@@ -53,7 +48,7 @@ return undefined; | ||
// @ts-expect-error | ||
arrayError[final_form_1.ARRAY_ERROR] = error; | ||
arrayError[ARRAY_ERROR] = error; | ||
return arrayError; | ||
} | ||
}); | ||
const _a = (0, react_final_form_1.useField)(name, { | ||
const _a = useField(name, { | ||
subscription: Object.assign(Object.assign({}, subscription), { length: true }), | ||
@@ -86,2 +81,2 @@ defaultValue, | ||
}; | ||
exports.default = useFieldArray; | ||
export default useFieldArray; |
{ | ||
"name": "@deckstar/react-final-form-arrays", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A component for rendering and editing arrays 🏁 React Final Form", | ||
@@ -35,3 +35,3 @@ "main": "dist/src", | ||
}, | ||
"gitHead": "02a9986e9607c99cebbdb47325c7bfe91c142891" | ||
"gitHead": "895075d667ee719aebe3992371956748e8c1059f" | ||
} |
30034
229