@balena/autoui
Advanced tools
Comparing version 0.4.0 to 0.4.1-build-fix-hook-error-9eb1da74bdcd1915b727d91364ca376440a487c2-1
import React from 'react'; | ||
import { AutoUIAction, AutoUIModel, AutoUIBaseResource, AutoUIContext, AutoUIRawModel, autoUIJsonSchemaPick, Priorities } from './schemaOps'; | ||
import { AutoUIAction, AutoUIModel, AutoUIBaseResource, AutoUIRawModel, autoUIJsonSchemaPick } from './schemaOps'; | ||
import type { JSONSchema7 as JSONSchema } from 'json-schema'; | ||
@@ -32,9 +32,1 @@ import { autoUIAddToSchema, autoUIDefaultPermissions, autoUIGetModelForCollection, autoUIRunTransformers } from './models/helpers'; | ||
}; | ||
export declare const getColumnsFromSchema: <T extends AutoUIBaseResource<T>>({ schema, idField, tagField, customSort, priorities, formats, }: { | ||
schema: JSONSchema; | ||
idField: string; | ||
tagField: string | undefined; | ||
customSort?: Dictionary<(a: T, b: T) => number> | undefined; | ||
priorities?: Priorities<T> | undefined; | ||
formats?: Format[] | undefined; | ||
}) => AutoUIEntityPropertyDefinition<T>[]; |
@@ -118,2 +118,3 @@ import { __assign, __makeTemplateObject, __rest, __spreadArray } from "tslib"; | ||
return getColumnsFromSchema({ | ||
t: t, | ||
schema: model.schema, | ||
@@ -187,4 +188,3 @@ idField: autouiContext.idField, | ||
export { autoUIRunTransformers, autoUIDefaultPermissions, autoUIGetModelForCollection, autoUIAddToSchema, autoUIJsonSchemaPick, autoUIGetDisabledReason, }; | ||
var getTitleAndLabel = function (jsonSchema, propertyKey, refScheme) { | ||
var t = useTranslation().t; | ||
var getTitleAndLabel = function (t, jsonSchema, propertyKey, refScheme) { | ||
var subSchema = sieve.getSubSchemaFromRefScheme(jsonSchema, refScheme); | ||
@@ -205,5 +205,5 @@ var title = (subSchema === null || subSchema === void 0 ? void 0 : subSchema.title) || jsonSchema.title || propertyKey; | ||
}; | ||
export var getColumnsFromSchema = function (_a) { | ||
var getColumnsFromSchema = function (_a) { | ||
var _b; | ||
var schema = _a.schema, idField = _a.idField, tagField = _a.tagField, customSort = _a.customSort, priorities = _a.priorities, formats = _a.formats; | ||
var t = _a.t, schema = _a.schema, idField = _a.idField, tagField = _a.tagField, customSort = _a.customSort, priorities = _a.priorities, formats = _a.formats; | ||
return Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {}) | ||
@@ -238,3 +238,3 @@ .filter(function (entry) { | ||
var widgetSchema = __assign(__assign({}, val), { title: undefined }); | ||
return __assign(__assign({}, getTitleAndLabel(val, key, refScheme === null || refScheme === void 0 ? void 0 : refScheme[0])), { field: key, key: "".concat(key, "_").concat(index), selected: getSelected(key, priorities), priority: priority, type: 'predefined', sortable: (_b = customSort === null || customSort === void 0 ? void 0 : customSort[key]) !== null && _b !== void 0 ? _b : getSortingFunction(key, val), render: function (fieldVal, entry) { | ||
return __assign(__assign({}, getTitleAndLabel(t, val, key, refScheme === null || refScheme === void 0 ? void 0 : refScheme[0])), { field: key, key: "".concat(key, "_").concat(index), selected: getSelected(key, priorities), priority: priority, type: 'predefined', sortable: (_b = customSort === null || customSort === void 0 ? void 0 : customSort[key]) !== null && _b !== void 0 ? _b : getSortingFunction(key, val), render: function (fieldVal, entry) { | ||
var calculatedField = autoUIAdaptRefScheme(fieldVal, val); | ||
@@ -241,0 +241,0 @@ return (React.createElement(CustomWidget, { extraFormats: __spreadArray(__spreadArray([], (formats !== null && formats !== void 0 ? formats : []), true), defaultFormats, true), schema: widgetSchema, value: calculatedField, extraContext: entry })); |
import React from 'react'; | ||
import { AutoUIAction, AutoUIModel, AutoUIBaseResource, AutoUIContext, AutoUIRawModel, autoUIJsonSchemaPick, Priorities } from './schemaOps'; | ||
import { AutoUIAction, AutoUIModel, AutoUIBaseResource, AutoUIRawModel, autoUIJsonSchemaPick } from './schemaOps'; | ||
import type { JSONSchema7 as JSONSchema } from 'json-schema'; | ||
@@ -32,9 +32,1 @@ import { autoUIAddToSchema, autoUIDefaultPermissions, autoUIGetModelForCollection, autoUIRunTransformers } from './models/helpers'; | ||
}; | ||
export declare const getColumnsFromSchema: <T extends AutoUIBaseResource<T>>({ schema, idField, tagField, customSort, priorities, formats, }: { | ||
schema: JSONSchema; | ||
idField: string; | ||
tagField: string | undefined; | ||
customSort?: Dictionary<(a: T, b: T) => number> | undefined; | ||
priorities?: Priorities<T> | undefined; | ||
formats?: Format[] | undefined; | ||
}) => AutoUIEntityPropertyDefinition<T>[]; |
@@ -41,3 +41,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getColumnsFromSchema = exports.autoUIGetDisabledReason = exports.autoUIJsonSchemaPick = exports.autoUIAddToSchema = exports.autoUIGetModelForCollection = exports.autoUIDefaultPermissions = exports.autoUIRunTransformers = exports.AutoUI = void 0; | ||
exports.autoUIGetDisabledReason = exports.autoUIJsonSchemaPick = exports.autoUIAddToSchema = exports.autoUIGetModelForCollection = exports.autoUIDefaultPermissions = exports.autoUIRunTransformers = exports.AutoUI = void 0; | ||
var react_1 = __importDefault(require("react")); | ||
@@ -164,3 +164,4 @@ var schemaOps_1 = require("./schemaOps"); | ||
var properties = react_1.default.useMemo(function () { | ||
return (0, exports.getColumnsFromSchema)({ | ||
return getColumnsFromSchema({ | ||
t: t, | ||
schema: model.schema, | ||
@@ -234,4 +235,3 @@ idField: autouiContext.idField, | ||
exports.AutoUI = AutoUI; | ||
var getTitleAndLabel = function (jsonSchema, propertyKey, refScheme) { | ||
var t = (0, useTranslation_1.useTranslation)().t; | ||
var getTitleAndLabel = function (t, jsonSchema, propertyKey, refScheme) { | ||
var subSchema = rendition_1.SchemaSieve.getSubSchemaFromRefScheme(jsonSchema, refScheme); | ||
@@ -254,3 +254,3 @@ var title = (subSchema === null || subSchema === void 0 ? void 0 : subSchema.title) || jsonSchema.title || propertyKey; | ||
var _b; | ||
var schema = _a.schema, idField = _a.idField, tagField = _a.tagField, customSort = _a.customSort, priorities = _a.priorities, formats = _a.formats; | ||
var t = _a.t, schema = _a.schema, idField = _a.idField, tagField = _a.tagField, customSort = _a.customSort, priorities = _a.priorities, formats = _a.formats; | ||
return Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {}) | ||
@@ -285,3 +285,3 @@ .filter(function (entry) { | ||
var widgetSchema = __assign(__assign({}, val), { title: undefined }); | ||
return __assign(__assign({}, getTitleAndLabel(val, key, refScheme === null || refScheme === void 0 ? void 0 : refScheme[0])), { field: key, key: "".concat(key, "_").concat(index), selected: (0, utils_1.getSelected)(key, priorities), priority: priority, type: 'predefined', sortable: (_b = customSort === null || customSort === void 0 ? void 0 : customSort[key]) !== null && _b !== void 0 ? _b : (0, utils_1.getSortingFunction)(key, val), render: function (fieldVal, entry) { | ||
return __assign(__assign({}, getTitleAndLabel(t, val, key, refScheme === null || refScheme === void 0 ? void 0 : refScheme[0])), { field: key, key: "".concat(key, "_").concat(index), selected: (0, utils_1.getSelected)(key, priorities), priority: priority, type: 'predefined', sortable: (_b = customSort === null || customSort === void 0 ? void 0 : customSort[key]) !== null && _b !== void 0 ? _b : (0, utils_1.getSortingFunction)(key, val), render: function (fieldVal, entry) { | ||
var calculatedField = (0, helpers_1.autoUIAdaptRefScheme)(fieldVal, val); | ||
@@ -293,3 +293,2 @@ return (react_1.default.createElement(CustomWidget_1.CustomWidget, { extraFormats: __spreadArray(__spreadArray([], (formats !== null && formats !== void 0 ? formats : []), true), rendition_1.defaultFormats, true), schema: widgetSchema, value: calculatedField, extraContext: entry })); | ||
}; | ||
exports.getColumnsFromSchema = getColumnsFromSchema; | ||
var templateObject_1; |
{ | ||
"name": "@balena/autoui", | ||
"version": "0.4.0", | ||
"version": "0.4.1-build-fix-hook-error-9eb1da74bdcd1915b727d91364ca376440a487c2-1", | ||
"description": "", | ||
@@ -93,4 +93,4 @@ "main": "./dist/index.js", | ||
"versionist": { | ||
"publishedAt": "2022-12-27T10:34:54.824Z" | ||
"publishedAt": "2022-12-28T13:10:10.070Z" | ||
} | ||
} |
290181
5323