@limetech/lime-elements 37.6.0 → 37.7.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 +8 -0
- package/dist/cjs/index.cjs.js +23 -8
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/limel-form.cjs.entry.js +1 -2
- package/dist/cjs/limel-form.cjs.entry.js.map +1 -1
- package/dist/collection/components/form/adapters/widget-adapter.js.map +1 -1
- package/dist/collection/components/form/form.js +14 -5
- package/dist/collection/components/form/form.js.map +1 -1
- package/dist/collection/components/form/form.types.js +1 -0
- package/dist/collection/components/form/form.types.js.map +1 -1
- package/dist/collection/components/form/help/help.js.map +1 -1
- package/dist/collection/components/form/templates/object-field.js +1 -2
- package/dist/collection/components/form/templates/object-field.js.map +1 -1
- package/dist/collection/components/form/templates/types.js.map +1 -1
- package/dist/collection/components/form/widgets/types.js.map +1 -1
- package/dist/esm/index.js +24 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/limel-form.entry.js +1 -2
- package/dist/esm/limel-form.entry.js.map +1 -1
- package/dist/lime-elements/index.esm.js +1 -1
- package/dist/lime-elements/index.esm.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-870d72f1.entry.js → p-64e352ec.entry.js} +5 -5
- package/dist/lime-elements/p-64e352ec.entry.js.map +1 -0
- package/dist/types/components/form/form.d.ts +3 -6
- package/dist/types/components/form/form.types.d.ts +37 -7
- package/dist/types/components/form/help/help.d.ts +2 -2
- package/dist/types/components/form/templates/types.d.ts +2 -2
- package/dist/types/components/form/widgets/types.d.ts +2 -2
- package/dist/types/components.d.ts +6 -12
- package/package.json +3 -3
- package/dist/cjs/form.types-e76a78e1.js +0 -26
- package/dist/cjs/form.types-e76a78e1.js.map +0 -1
- package/dist/collection/components/form/internal.types.js +0 -2
- package/dist/collection/components/form/internal.types.js.map +0 -1
- package/dist/esm/form.types-e39f98a4.js +0 -26
- package/dist/esm/form.types-e39f98a4.js.map +0 -1
- package/dist/lime-elements/p-067efbaf.js +0 -2
- package/dist/lime-elements/p-067efbaf.js.map +0 -1
- package/dist/lime-elements/p-870d72f1.entry.js.map +0 -1
- package/dist/types/components/form/internal.types.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [37.7.0](https://github.com/Lundalogik/lime-elements/compare/v37.6.0...v37.7.0) (2024-02-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
* **form:** expose json schema interface ([e9c426f](https://github.com/Lundalogik/lime-elements/commit/e9c426fcc1b6a62ef97133b971fd13f8dd472520))
|
|
8
|
+
|
|
1
9
|
## [37.6.0](https://github.com/Lundalogik/lime-elements/compare/v37.5.0...v37.6.0) (2024-02-28)
|
|
2
10
|
|
|
3
11
|
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -2,7 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
* Represents the layout types for a form.
|
|
8
|
+
*/
|
|
9
|
+
exports.FormLayoutType = void 0;
|
|
10
|
+
(function (FormLayoutType) {
|
|
11
|
+
/**
|
|
12
|
+
* The default layout
|
|
13
|
+
*/
|
|
14
|
+
FormLayoutType["Default"] = "default";
|
|
15
|
+
/**
|
|
16
|
+
* Render the form fields using a responsive grid layout
|
|
17
|
+
*/
|
|
18
|
+
FormLayoutType["Grid"] = "grid";
|
|
19
|
+
/**
|
|
20
|
+
* Render the form fields in full-width rows.
|
|
21
|
+
* Each row can have a leading `icon`, and a field.
|
|
22
|
+
* `title` and `description` provided by the schema will be placed
|
|
23
|
+
* on the row itself, and not on the field.
|
|
24
|
+
* This layout is good for creating UIs for user settings pages.
|
|
25
|
+
*/
|
|
26
|
+
FormLayoutType["Row"] = "row";
|
|
27
|
+
})(exports.FormLayoutType || (exports.FormLayoutType = {}));
|
|
6
28
|
|
|
7
29
|
/**
|
|
8
30
|
* The built-in aggregators available for columns
|
|
@@ -32,11 +54,4 @@ exports.ColumnAggregatorType = void 0;
|
|
|
32
54
|
ColumnAggregatorType["Count"] = "count";
|
|
33
55
|
})(exports.ColumnAggregatorType || (exports.ColumnAggregatorType = {}));
|
|
34
56
|
|
|
35
|
-
Object.defineProperty(exports, 'FormLayoutType', {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return form_types.FormLayoutType;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
57
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index.cjs.js","mappings":";;;;;;AAqJA;;;;AAIYA;AAAZ,WAAY,oBAAoB;;;;EAI5B,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,mCAAW,CAAA;;;;EAKX,uCAAe,CAAA;AACnB,CAAC,EAzBWA,4BAAoB,KAApBA,4BAAoB;;;;;;;;;","names":["ColumnAggregatorType"],"sources":["./src/components/table/table.types.ts"],"sourcesContent":["/**\n * Defines the data for a table\n * @public\n */\nexport interface Column<T extends object = any> {\n /**\n * Column title to be displayed\n */\n title: string;\n\n /**\n * Name of the field in the data\n */\n field: keyof T;\n\n /**\n * Function to format the value before rendering\n */\n formatter?: TableFormatter;\n\n /**\n * Component used to render the field value\n */\n component?: TableComponentDefinition;\n\n /**\n * Type of aggregator to use for the column\n */\n aggregator?: ColumnAggregatorType | ColumnAggregatorFunction<T>;\n\n /**\n * A component used to render inside the column header\n */\n headerComponent?: TableComponentDefinition;\n\n /**\n * Sets the horizontal text alignment for the column\n */\n horizontalAlign?: 'left' | 'center' | 'right';\n\n /**\n * Defines whether end-user can sort a column\n */\n headerSort?: boolean;\n}\n\n/**\n * Definition for a formatter function\n * @param value - The value to be formatted\n * @param data - The data for the current row\n * @returns The formatted value\n * @public\n */\nexport type TableFormatter = (value: any, data?: object) => string;\n\n/**\n * The `component` key in the schema uses this interface to define a\n * component to be rendered inside a cell in the table.\n *\n * @note The table will display the component as `inline-block` in order\n * to give the column the correct size. If the component should have the\n * full width of the column, this might have to be overridden by setting\n * the display mode to `block`, e.g.\n *\n * ```css\n * :host(*) {\n * display: block !important;\n * }\n * ```\n * @public\n */\nexport interface TableComponentDefinition {\n /**\n * Name of the component\n */\n name: string;\n\n /**\n * Properties to send to the component\n */\n props?: Record<string, any>;\n\n /**\n * Factory for creating properties dynamically for a custom component.\n *\n * The properties returned from this function will be merged with the\n * `props` properties when the component is created.\n *\n * When the propsFactory is used for header components there will be no data available.\n *\n * @param data - The data for the current row\n * @returns Properties for the component\n */\n propsFactory?: (data: object) => Record<string, any>;\n}\n\n/**\n * Interface for custom components rendered inside a `limel-table`.\n * @public\n */\nexport interface TableComponent<T extends object = any> {\n /**\n * Name of the field being rendered\n */\n field?: string;\n\n /**\n * Value being rendered\n */\n value?: any;\n\n /**\n * Data for the current row of the table\n */\n data?: T;\n}\n\n/**\n * Indicates whether the specified column is sorted ascending or descending.\n * @public\n */\nexport interface ColumnSorter {\n /**\n * The column being sorted\n */\n column: Column;\n\n /**\n * The direction to sort on\n */\n direction: 'ASC' | 'DESC';\n}\n\n/**\n * Specifies the current page, and which columns the table is currently sorted on.\n * @public\n */\nexport interface TableParams {\n /**\n * The current page being set\n */\n page: number;\n\n /**\n * Sorters applied to the current page\n */\n sorters?: ColumnSorter[];\n}\n\n/**\n * The built-in aggregators available for columns\n * @public\n */\nexport enum ColumnAggregatorType {\n /**\n * Calculates the average value of all numerical cells in the column\n */\n Average = 'avg',\n\n /**\n * Displays the maximum value from all numerical cells in the column\n */\n Maximum = 'max',\n\n /**\n * Displays the minimum value from all numerical cells in the column\n */\n Minimum = 'min',\n\n /**\n * Displays the sum of all numerical cells in the column\n */\n Sum = 'sum',\n\n /**\n * Counts the number of non empty cells in the column\n */\n Count = 'count',\n}\n\n/**\n * Instead of using one of the built-in aggregators, it is possible to\n * define a custom aggregator function.\n *\n * @param column - the configuration for the column\n * @param values - list of all values to be aggregated\n * @param data - list of all objects to be aggregated\n * @returns the aggregated data\n *\n * @public\n */\nexport type ColumnAggregatorFunction<T = object> = (\n column?: Column,\n values?: any[],\n data?: T[],\n) => any;\n\n/**\n * Defines aggregate values for columns\n * @public\n */\nexport interface ColumnAggregate {\n /**\n * The name of the `Column` field\n */\n field: string;\n /**\n * The aggregate value\n */\n value: any;\n}\n"],"version":3}
|
|
1
|
+
{"file":"index.cjs.js","mappings":";;;;AAiSA;;;;AAIYA;AAAZ,WAAY,cAAc;;;;EAItB,qCAAmB,CAAA;;;;EAKnB,+BAAa,CAAA;;;;;;;;EASb,6BAAW,CAAA;AACf,CAAC,EAnBWA,sBAAc,KAAdA,sBAAc;;AChJ1B;;;;AAIYC;AAAZ,WAAY,oBAAoB;;;;EAI5B,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,uCAAe,CAAA;;;;EAKf,mCAAW,CAAA;;;;EAKX,uCAAe,CAAA;AACnB,CAAC,EAzBWA,4BAAoB,KAApBA,4BAAoB;;","names":["FormLayoutType","ColumnAggregatorType"],"sources":["./src/components/form/form.types.ts","./src/components/table/table.types.ts"],"sourcesContent":["import { JSONSchema7 } from 'json-schema';\nimport { Help } from '../help/help.types';\nimport { EventEmitter } from '@stencil/core';\n\ndeclare module 'json-schema' {\n interface JSONSchema7 {\n /**\n * @internal\n * Unique identifier for the schema\n */\n id?: string;\n\n /**\n * Lime elements specific options that can be specified in a schema\n */\n lime?: Omit<LimeSchemaOptions, 'layout'> & {\n layout?: Partial<LimeLayoutOptions>;\n };\n }\n}\n\n/**\n * @public\n */\nexport interface ValidationStatus {\n /**\n * True if the form is valid, false otherwise\n *\n * If the form is invalid, any errors can be found on the `errors` property\n */\n valid: boolean;\n\n /**\n * List of validation errors\n */\n errors?: FormError[];\n}\n\n/**\n * @public\n */\nexport interface FormError {\n /**\n * Name of the error\n */\n name: string;\n\n /**\n * Params of the error\n */\n params?: unknown;\n\n /**\n * Name of the invalid property\n */\n property: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath: string;\n\n /**\n * String describing the error\n */\n message: string;\n}\n\n/**\n * @public\n */\nexport type ValidationError = {\n /**\n * Name of the field the error belongs to\n */\n [key: string]: string[] | ValidationError;\n};\n\n/**\n * @public\n */\nexport interface FormComponent<T = any> {\n /**\n * The value of the current property\n */\n value: T;\n\n /**\n * Whether or not the current property is required\n */\n required?: boolean;\n\n /**\n * Whether or not the current property is readonly\n */\n readonly?: boolean;\n\n /**\n * Whether or not the current property is disabled\n */\n disabled?: boolean;\n\n /**\n * The label of the current property\n */\n label?: string;\n\n /**\n * The helper text for the current property\n */\n helperText?: string;\n\n /**\n * Additional contextual information about the form\n */\n formInfo?: FormInfo;\n\n /**\n * The event to emit when the value of the current property has changed\n */\n change: EventEmitter<T>;\n}\n\n/**\n * @public\n */\nexport interface FormInfo {\n /**\n * The schema of the current property\n */\n schema?: FormSchema;\n\n /**\n * The schema of the whole form\n */\n rootSchema?: FormSchema;\n\n /**\n * A tree of errors for this property and its children\n */\n errorSchema?: object;\n\n /**\n * The value of the whole form\n */\n rootValue?: any;\n\n /**\n * The name of the current property\n */\n name?: string;\n\n /**\n * Path to the property within the schema\n */\n schemaPath?: string[];\n}\n\n/**\n * Lime elements specific options that can be specified under the `lime` key in\n * a schema, e.g.\n *\n * ```ts\n * const schema = {\n * type: 'object',\n * lime: {\n * collapsible: true,\n * },\n * };\n * ```\n *\n * @public\n */\nexport interface LimeSchemaOptions {\n /**\n * When specified on an object it will render all sub components inside a\n * collapsible section\n */\n collapsible?: boolean;\n\n /**\n * When `collapsible` is `true`, set this to `false` to make the\n * collapsible section load in the open state.\n * Defaults to `true`.\n */\n collapsed?: boolean;\n\n /**\n * Will render the field using the specified component. The component\n * should implement the `FormComponent` interface\n */\n component?: FormComponentOptions;\n\n /**\n * When specified on an object it will render the sub components with the\n * specified layout\n */\n layout?: LimeLayoutOptions;\n\n /**\n * Mark the field as disabled\n */\n disabled?: boolean;\n\n help?: string | Partial<Help>;\n}\n\n/**\n * @public\n * Options for a layout to be used in a form\n */\nexport type LimeLayoutOptions = GridLayoutOptions & RowLayoutOptions;\n\n/**\n * Options for a component to be rendered inside a form\n *\n * @public\n */\nexport interface FormComponentOptions {\n /**\n * Name of the component\n */\n name?: string;\n\n /**\n * Extra properties to give the component in addition to the properties\n * specified on the `FormComponent` interface\n */\n props?: Record<string, any>;\n}\n\n/**\n * @public\n */\nexport interface FormLayoutOptions<\n T extends FormLayoutType | `${FormLayoutType}` = FormLayoutType.Default,\n> {\n /**\n * The type of layout to use\n */\n type: T;\n}\n\n/**\n * @public\n * Layout options for a grid layout\n */\nexport interface GridLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of columns in the form\n */\n // eslint-disable-next-line no-magic-numbers\n colSpan?: 1 | 2 | 3 | 4 | 5 | 'all';\n\n /**\n * When specified on a component within the grid, the component will take\n * up the the specified number of rows in the form\n */\n rowSpan?: number;\n\n /**\n * Number of columns to use in the layout\n */\n // eslint-disable-next-line no-magic-numbers\n columns?: 1 | 2 | 3 | 4 | 5;\n\n /**\n * Attempts to fill in holes earlier in the grid, if smaller items come up\n * later. This may cause items to appear out-of-order, when doing so would\n * fill holes left by larger items. Defaults to `true`.\n */\n dense?: boolean;\n}\n\n/**\n * @public\n * Layout options for a row layout\n */\nexport interface RowLayoutOptions\n extends FormLayoutOptions<FormLayoutType | `${FormLayoutType}`> {\n /**\n * When specified on a field, the chosen icon will be displayed\n * on the left side of the row, beside the title.\n */\n icon?: string;\n}\n\n/**\n * @public\n * Represents the layout types for a form.\n */\nexport enum FormLayoutType {\n /**\n * The default layout\n */\n Default = 'default',\n\n /**\n * Render the form fields using a responsive grid layout\n */\n Grid = 'grid',\n\n /**\n * Render the form fields in full-width rows.\n * Each row can have a leading `icon`, and a field.\n * `title` and `description` provided by the schema will be placed\n * on the row itself, and not on the field.\n * This layout is good for creating UIs for user settings pages.\n */\n Row = 'row',\n}\n\n/**\n * @public\n * Represents the JSON schema with Lime specific options\n */\nexport interface FormSchema extends JSONSchema7 {}\n","/**\n * Defines the data for a table\n * @public\n */\nexport interface Column<T extends object = any> {\n /**\n * Column title to be displayed\n */\n title: string;\n\n /**\n * Name of the field in the data\n */\n field: keyof T;\n\n /**\n * Function to format the value before rendering\n */\n formatter?: TableFormatter;\n\n /**\n * Component used to render the field value\n */\n component?: TableComponentDefinition;\n\n /**\n * Type of aggregator to use for the column\n */\n aggregator?: ColumnAggregatorType | ColumnAggregatorFunction<T>;\n\n /**\n * A component used to render inside the column header\n */\n headerComponent?: TableComponentDefinition;\n\n /**\n * Sets the horizontal text alignment for the column\n */\n horizontalAlign?: 'left' | 'center' | 'right';\n\n /**\n * Defines whether end-user can sort a column\n */\n headerSort?: boolean;\n}\n\n/**\n * Definition for a formatter function\n * @param value - The value to be formatted\n * @param data - The data for the current row\n * @returns The formatted value\n * @public\n */\nexport type TableFormatter = (value: any, data?: object) => string;\n\n/**\n * The `component` key in the schema uses this interface to define a\n * component to be rendered inside a cell in the table.\n *\n * @note The table will display the component as `inline-block` in order\n * to give the column the correct size. If the component should have the\n * full width of the column, this might have to be overridden by setting\n * the display mode to `block`, e.g.\n *\n * ```css\n * :host(*) {\n * display: block !important;\n * }\n * ```\n * @public\n */\nexport interface TableComponentDefinition {\n /**\n * Name of the component\n */\n name: string;\n\n /**\n * Properties to send to the component\n */\n props?: Record<string, any>;\n\n /**\n * Factory for creating properties dynamically for a custom component.\n *\n * The properties returned from this function will be merged with the\n * `props` properties when the component is created.\n *\n * When the propsFactory is used for header components there will be no data available.\n *\n * @param data - The data for the current row\n * @returns Properties for the component\n */\n propsFactory?: (data: object) => Record<string, any>;\n}\n\n/**\n * Interface for custom components rendered inside a `limel-table`.\n * @public\n */\nexport interface TableComponent<T extends object = any> {\n /**\n * Name of the field being rendered\n */\n field?: string;\n\n /**\n * Value being rendered\n */\n value?: any;\n\n /**\n * Data for the current row of the table\n */\n data?: T;\n}\n\n/**\n * Indicates whether the specified column is sorted ascending or descending.\n * @public\n */\nexport interface ColumnSorter {\n /**\n * The column being sorted\n */\n column: Column;\n\n /**\n * The direction to sort on\n */\n direction: 'ASC' | 'DESC';\n}\n\n/**\n * Specifies the current page, and which columns the table is currently sorted on.\n * @public\n */\nexport interface TableParams {\n /**\n * The current page being set\n */\n page: number;\n\n /**\n * Sorters applied to the current page\n */\n sorters?: ColumnSorter[];\n}\n\n/**\n * The built-in aggregators available for columns\n * @public\n */\nexport enum ColumnAggregatorType {\n /**\n * Calculates the average value of all numerical cells in the column\n */\n Average = 'avg',\n\n /**\n * Displays the maximum value from all numerical cells in the column\n */\n Maximum = 'max',\n\n /**\n * Displays the minimum value from all numerical cells in the column\n */\n Minimum = 'min',\n\n /**\n * Displays the sum of all numerical cells in the column\n */\n Sum = 'sum',\n\n /**\n * Counts the number of non empty cells in the column\n */\n Count = 'count',\n}\n\n/**\n * Instead of using one of the built-in aggregators, it is possible to\n * define a custom aggregator function.\n *\n * @param column - the configuration for the column\n * @param values - list of all values to be aggregated\n * @param data - list of all objects to be aggregated\n * @returns the aggregated data\n *\n * @public\n */\nexport type ColumnAggregatorFunction<T = object> = (\n column?: Column,\n values?: any[],\n data?: T[],\n) => any;\n\n/**\n * Defines aggregate values for columns\n * @public\n */\nexport interface ColumnAggregate {\n /**\n * The name of the `Column` field\n */\n field: string;\n /**\n * The aggregate value\n */\n value: any;\n}\n"],"version":3}
|
|
@@ -8,7 +8,6 @@ const isEqual$1 = require('./isEqual-d2a13a24.js');
|
|
|
8
8
|
const isArray$4 = require('./isArray-d188a04f.js');
|
|
9
9
|
const isArrayLike$1 = require('./isArrayLike-ac53bdac.js');
|
|
10
10
|
const pickBy = require('./pickBy-3ef47bf2.js');
|
|
11
|
-
const form_types = require('./form.types-e76a78e1.js');
|
|
12
11
|
const identity$1 = require('./identity-6dc34885.js');
|
|
13
12
|
const _assignValue$1 = require('./_assignValue-7c18d8d6.js');
|
|
14
13
|
const isObject$3 = require('./isObject-e28b7997.js');
|
|
@@ -24158,7 +24157,7 @@ function renderProperties(properties, schema) {
|
|
|
24158
24157
|
return renderLayout(properties, layout);
|
|
24159
24158
|
}
|
|
24160
24159
|
function renderLayout(properties, layout) {
|
|
24161
|
-
const type = (layout === null || layout === void 0 ? void 0 : layout.type) ||
|
|
24160
|
+
const type = (layout === null || layout === void 0 ? void 0 : layout.type) || 'default';
|
|
24162
24161
|
const layouts = {
|
|
24163
24162
|
default: renderDefaultLayout,
|
|
24164
24163
|
grid: renderGridLayout,
|