@omegagrid/form 0.2.5
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/constants.d.ts +45 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/model/formAdapter.d.ts +13 -0
- package/dist/model/formAdapter.d.ts.map +1 -0
- package/dist/model/formAdapter.js +24 -0
- package/dist/model/formAdapter.js.map +1 -0
- package/dist/model/formControlModel.d.ts +9 -0
- package/dist/model/formControlModel.d.ts.map +1 -0
- package/dist/model/formControlModel.js +13 -0
- package/dist/model/formControlModel.js.map +1 -0
- package/dist/model/formModel.d.ts +17 -0
- package/dist/model/formModel.d.ts.map +1 -0
- package/dist/model/formModel.js +49 -0
- package/dist/model/formModel.js.map +1 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +20 -0
- package/dist/model/index.js.map +1 -0
- package/dist/options.d.ts +3 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +21 -0
- package/dist/options.js.map +1 -0
- package/dist/types.d.ts +89 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/controls/baseControl.d.ts +30 -0
- package/dist/ui/controls/baseControl.d.ts.map +1 -0
- package/dist/ui/controls/baseControl.js +85 -0
- package/dist/ui/controls/baseControl.js.map +1 -0
- package/dist/ui/controls/button.d.ts +16 -0
- package/dist/ui/controls/button.d.ts.map +1 -0
- package/dist/ui/controls/button.js +70 -0
- package/dist/ui/controls/button.js.map +1 -0
- package/dist/ui/controls/checkbox.d.ts +7 -0
- package/dist/ui/controls/checkbox.d.ts.map +1 -0
- package/dist/ui/controls/checkbox.js +29 -0
- package/dist/ui/controls/checkbox.js.map +1 -0
- package/dist/ui/controls/colorInput.d.ts +8 -0
- package/dist/ui/controls/colorInput.d.ts.map +1 -0
- package/dist/ui/controls/colorInput.js +41 -0
- package/dist/ui/controls/colorInput.js.map +1 -0
- package/dist/ui/controls/index.d.ts +8 -0
- package/dist/ui/controls/index.d.ts.map +1 -0
- package/dist/ui/controls/index.js +24 -0
- package/dist/ui/controls/index.js.map +1 -0
- package/dist/ui/controls/label.d.ts +6 -0
- package/dist/ui/controls/label.d.ts.map +1 -0
- package/dist/ui/controls/label.js +54 -0
- package/dist/ui/controls/label.js.map +1 -0
- package/dist/ui/controls/list.d.ts +16 -0
- package/dist/ui/controls/list.d.ts.map +1 -0
- package/dist/ui/controls/list.js +83 -0
- package/dist/ui/controls/list.js.map +1 -0
- package/dist/ui/controls/numericInput.d.ts +15 -0
- package/dist/ui/controls/numericInput.d.ts.map +1 -0
- package/dist/ui/controls/numericInput.js +135 -0
- package/dist/ui/controls/numericInput.js.map +1 -0
- package/dist/ui/controls/textInput.d.ts +8 -0
- package/dist/ui/controls/textInput.d.ts.map +1 -0
- package/dist/ui/controls/textInput.js +61 -0
- package/dist/ui/controls/textInput.js.map +1 -0
- package/dist/ui/form.d.ts +34 -0
- package/dist/ui/form.d.ts.map +1 -0
- package/dist/ui/form.js +195 -0
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/form.style.d.ts +2 -0
- package/dist/ui/form.style.d.ts.map +1 -0
- package/dist/ui/form.style.js +39 -0
- package/dist/ui/form.style.js.map +1 -0
- package/dist/ui/formContainer.d.ts +28 -0
- package/dist/ui/formContainer.d.ts.map +1 -0
- package/dist/ui/formContainer.js +178 -0
- package/dist/ui/formContainer.js.map +1 -0
- package/dist/ui/formContainer.style.d.ts +2 -0
- package/dist/ui/formContainer.style.d.ts.map +1 -0
- package/dist/ui/formContainer.style.js +48 -0
- package/dist/ui/formContainer.style.js.map +1 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +20 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FormButtonConfig, FormButtonType } from './types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
LOCALE: string;
|
|
4
|
+
PREFIX: string;
|
|
5
|
+
DEFAULT_ACCENT_COLOR: string;
|
|
6
|
+
DEFAULT_ACCENT_COLOR_2: import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<string | number | ArrayLike<number> | import("color")<any> | {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}> | {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}> | {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}> | {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}> | {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}> | {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}> | {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}> | {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}> | {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}> | {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}> | {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}>;
|
|
29
|
+
SIZER_SIZE: number;
|
|
30
|
+
SLIDER_SIZE: number;
|
|
31
|
+
SLIDER_MIN_LENGTH: number;
|
|
32
|
+
EXPANDER_SIZE: number;
|
|
33
|
+
LIST_ITEM_HEIGHT: number;
|
|
34
|
+
LIST_RENDERING_TRESHOLD: number;
|
|
35
|
+
LIST_AUTOSCROLL_TRESHOLD: number;
|
|
36
|
+
LIST_AUTOSCROLL_DELAY: number;
|
|
37
|
+
DEFAULT_TEXT_HIGHLIGHT_COLOR: string;
|
|
38
|
+
TOOLTIP_MARGIN: number;
|
|
39
|
+
MENU_ITEM_HEIGHT: number;
|
|
40
|
+
COLORPICKER_COLOR_SIZE: number;
|
|
41
|
+
FORM_CONTROL_HEIGHT: number;
|
|
42
|
+
BUTTON_CONFIG: Map<FormButtonType, FormButtonConfig>;
|
|
43
|
+
};
|
|
44
|
+
export default _default;
|
|
45
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,wBAUC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@omegagrid/core");
|
|
4
|
+
exports.default = {
|
|
5
|
+
FORM_CONTROL_HEIGHT: 20,
|
|
6
|
+
BUTTON_CONFIG: new Map([
|
|
7
|
+
['save', { text: 'Save', color: core_1.ColorTypes.Accent, default: true }],
|
|
8
|
+
['reset', { text: 'Reset', color: core_1.ColorTypes.Gray }],
|
|
9
|
+
['validate', { text: 'Validate', color: core_1.ColorTypes.Gray }],
|
|
10
|
+
['storno', { text: 'Storno', color: core_1.ColorTypes.Gray }],
|
|
11
|
+
['close', { text: 'Close', color: core_1.ColorTypes.Gray }]
|
|
12
|
+
]),
|
|
13
|
+
...core_1.constants
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;AAAA,0CAAyE;AAGzE,kBAAe;IACd,mBAAmB,EAAE,EAAE;IACvB,aAAa,EAAE,IAAI,GAAG,CAAmC;QACxD,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;QACjE,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAU,CAAC,IAAI,EAAC,CAAC;QAClD,CAAC,UAAU,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,iBAAU,CAAC,IAAI,EAAC,CAAC;QACxD,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAU,CAAC,IAAI,EAAC,CAAC;QACpD,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAU,CAAC,IAAI,EAAC,CAAC;KAClD,CAAC;IACF,GAAG,gBAAa;CAChB,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ui"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./model"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,0CAAwB;AACxB,0CAAwB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentAdapter } from '@omegagrid/core';
|
|
2
|
+
import { Form } from '../ui';
|
|
3
|
+
import { FormSettings, FormColumn, FormControlProperties, FormRow, FormValues, FormAlert } from '../types';
|
|
4
|
+
import { FormContainerOptions } from '../types';
|
|
5
|
+
export declare abstract class FormAdapter extends ComponentAdapter<Form> {
|
|
6
|
+
getForms(): FormSettings[] | Promise<FormSettings[]>;
|
|
7
|
+
getRows(id: string | number): FormRow[] | Promise<FormRow[]>;
|
|
8
|
+
getColumns(id: string | number): FormColumn[] | Promise<FormColumn[]>;
|
|
9
|
+
abstract getControls(id: string | number): FormControlProperties[] | Promise<FormControlProperties[]>;
|
|
10
|
+
save(values: Map<string | number, FormValues>): boolean | FormAlert[] | Promise<boolean | FormAlert[]>;
|
|
11
|
+
getOptions(): FormContainerOptions | Promise<FormContainerOptions>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=formAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAdapter.d.ts","sourceRoot":"","sources":["../../src/model/formAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,8BAAsB,WAAY,SAAQ,gBAAgB,CAAC,IAAI,CAAC;IAE/D,QAAQ,IAAI,YAAY,EAAE,GAAC,OAAO,CAAC,YAAY,EAAE,CAAC;IAIlD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,EAAE,GAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAIxD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAC,MAAM,GAAG,UAAU,EAAE,GAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IAIjE,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAC,MAAM,GAAG,qBAAqB,EAAE,GAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAEjG,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAC,MAAM,EAAE,UAAU,CAAC,GAAG,OAAO,GAAC,SAAS,EAAE,GAAC,OAAO,CAAC,OAAO,GAAC,SAAS,EAAE,CAAC;IAI9F,UAAU,IAAI,oBAAoB,GAAC,OAAO,CAAC,oBAAoB,CAAC;CAIhE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.FormAdapter = void 0;
|
|
5
|
+
const core_1 = require("@omegagrid/core");
|
|
6
|
+
class FormAdapter extends core_1.ComponentAdapter {
|
|
7
|
+
getForms() {
|
|
8
|
+
return [{ key: 0 }];
|
|
9
|
+
}
|
|
10
|
+
getRows(id) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
getColumns(id) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
save(values) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
getOptions() {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.FormAdapter = FormAdapter;
|
|
24
|
+
//# sourceMappingURL=formAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formAdapter.js","sourceRoot":"","sources":["../../src/model/formAdapter.ts"],"names":[],"mappings":";AAAA,sDAAsD;;;AAEtD,0CAAmD;AAKnD,MAAsB,WAAY,SAAQ,uBAAsB;IAE/D,QAAQ;QACP,OAAO,CAAC,EAAC,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,EAAiB;QACxB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,UAAU,CAAC,EAAiB;QAC3B,OAAO,EAAE,CAAC;IACX,CAAC;IAID,IAAI,CAAC,MAAsC;QAC1C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,UAAU;QACT,OAAO,EAAE,CAAC;IACX,CAAC;CAED;AAxBD,kCAwBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FormControlProperties } from "../types";
|
|
2
|
+
export declare class FormControlModel {
|
|
3
|
+
readonly props: FormControlProperties;
|
|
4
|
+
readonly dependencies: FormControlModel[];
|
|
5
|
+
errors: string[];
|
|
6
|
+
constructor(props: FormControlProperties);
|
|
7
|
+
get key(): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=formControlModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formControlModel.d.ts","sourceRoot":"","sources":["../../src/model/formControlModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,qBAAa,gBAAgB;aAMA,KAAK,EAAE,qBAAqB;IAJxD,SAAgB,YAAY,EAAE,gBAAgB,EAAE,CAAM;IAE/C,MAAM,EAAE,MAAM,EAAE,CAAM;gBAED,KAAK,EAAE,qBAAqB;IAExD,IAAI,GAAG,WAA4B;CAEnC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormControlModel = void 0;
|
|
4
|
+
class FormControlModel {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
this.props = props;
|
|
7
|
+
this.dependencies = [];
|
|
8
|
+
this.errors = [];
|
|
9
|
+
}
|
|
10
|
+
get key() { return this.props.key; }
|
|
11
|
+
}
|
|
12
|
+
exports.FormControlModel = FormControlModel;
|
|
13
|
+
//# sourceMappingURL=formControlModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formControlModel.js","sourceRoot":"","sources":["../../src/model/formControlModel.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAM5B,YAA4B,KAA4B;QAA5B,UAAK,GAAL,KAAK,CAAuB;QAJxC,iBAAY,GAAuB,EAAE,CAAC;QAE/C,WAAM,GAAa,EAAE,CAAC;IAE+B,CAAC;IAE7D,IAAI,GAAG,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA,CAAC,CAAC;CAEnC;AAVD,4CAUC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FormColumn, FormOptions, FormRow, FormSettings } from "../types";
|
|
2
|
+
import { FormControlModel } from "./formControlModel";
|
|
3
|
+
export declare class FormModel {
|
|
4
|
+
options: FormOptions;
|
|
5
|
+
controls: FormControlModel[][];
|
|
6
|
+
rows: FormRow[];
|
|
7
|
+
columns: FormColumn[];
|
|
8
|
+
private _rowCount;
|
|
9
|
+
private _colCount;
|
|
10
|
+
get rowCount(): number;
|
|
11
|
+
get colCount(): number;
|
|
12
|
+
readonly controlMap: Map<string, FormControlModel>;
|
|
13
|
+
get(key: string): FormControlModel;
|
|
14
|
+
constructor(sourceData: FormSettings);
|
|
15
|
+
populate(sourceData: FormSettings): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=formModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formModel.d.ts","sourceRoot":"","sources":["../../src/model/formModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,SAAS;IAErB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;IAC/B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,OAAO,EAAE,UAAU,EAAE,CAAC;IAEtB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,SAAS,CAAK;IAEtB,IAAI,QAAQ,WAA4B;IACxC,IAAI,QAAQ,WAA4B;IAExC,SAAgB,UAAU,gCAAuC;IAEjE,GAAG,CAAC,GAAG,EAAE,MAAM;gBAEH,UAAU,EAAE,YAAY;IAIpC,QAAQ,CAAC,UAAU,EAAE,YAAY;CA+BjC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormModel = void 0;
|
|
4
|
+
const formControlModel_1 = require("./formControlModel");
|
|
5
|
+
class FormModel {
|
|
6
|
+
get rowCount() { return this._rowCount; }
|
|
7
|
+
get colCount() { return this._colCount; }
|
|
8
|
+
get(key) { return this.controlMap.get(key); }
|
|
9
|
+
constructor(sourceData) {
|
|
10
|
+
this._rowCount = 0;
|
|
11
|
+
this._colCount = 0;
|
|
12
|
+
this.controlMap = new Map();
|
|
13
|
+
this.populate(sourceData);
|
|
14
|
+
}
|
|
15
|
+
populate(sourceData) {
|
|
16
|
+
var _a;
|
|
17
|
+
this.options = (_a = sourceData.options) !== null && _a !== void 0 ? _a : {};
|
|
18
|
+
this.controlMap.clear();
|
|
19
|
+
this.controls = [];
|
|
20
|
+
this.rows = sourceData.rows || [];
|
|
21
|
+
this.columns = sourceData.columns || [];
|
|
22
|
+
this._rowCount = this.rows.length;
|
|
23
|
+
this._colCount = this.columns.length;
|
|
24
|
+
sourceData.controls.forEach(c => {
|
|
25
|
+
var _a;
|
|
26
|
+
this._rowCount = Math.max(this._rowCount, c.row + 1);
|
|
27
|
+
this._colCount = Math.max(this._colCount, c.col + 1);
|
|
28
|
+
if (this._rowCount > this.rows.length)
|
|
29
|
+
this.rows.push({});
|
|
30
|
+
if (this._colCount > this.columns.length)
|
|
31
|
+
this.columns.push({});
|
|
32
|
+
c.key = (_a = c.key) !== null && _a !== void 0 ? _a : ((c.row * this._colCount) + c.col).toString();
|
|
33
|
+
this.controlMap.set(c.key, new formControlModel_1.FormControlModel(c));
|
|
34
|
+
});
|
|
35
|
+
this.controls = [...Array(this.rowCount)].map(() => Array(this.colCount));
|
|
36
|
+
this.controlMap.forEach(c => {
|
|
37
|
+
var _a;
|
|
38
|
+
this.controls[c.props.row][c.props.col] = c;
|
|
39
|
+
if (c.props.dependsOn) {
|
|
40
|
+
this.controlMap.get(c.props.dependsOn).dependencies.push(c);
|
|
41
|
+
}
|
|
42
|
+
if (c.props.for && ((_a = this.controlMap.get(c.props.for)) === null || _a === void 0 ? void 0 : _a.props.required)) {
|
|
43
|
+
c.props.required = true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.FormModel = FormModel;
|
|
49
|
+
//# sourceMappingURL=formModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formModel.js","sourceRoot":"","sources":["../../src/model/formModel.ts"],"names":[],"mappings":";;;AACA,yDAAsD;AAEtD,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K,CAAC,QAAQ,CAAA,EAAE,CAAC;gBACrE,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;YACzB,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CAED;AApDD,8BAoDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./formAdapter"), exports);
|
|
18
|
+
__exportStar(require("./formModel"), exports);
|
|
19
|
+
__exportStar(require("./formControlModel"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8CAA4B;AAC5B,qDAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAU/C,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,WAAW,GAAE,oBAA2B,GAAG,oBAAoB,CAOnI"}
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initOptions = void 0;
|
|
4
|
+
const core_1 = require("@omegagrid/core");
|
|
5
|
+
const DEFAULT_OPTIONS = {
|
|
6
|
+
caption: null,
|
|
7
|
+
buttonsPosition: 'bottom',
|
|
8
|
+
alertsPosition: 'bottom',
|
|
9
|
+
buttons: [],
|
|
10
|
+
closeAfterSave: true
|
|
11
|
+
};
|
|
12
|
+
function initOptions(options, origOptions = null) {
|
|
13
|
+
return {
|
|
14
|
+
...(0, core_1.initCommonOptions)(options, origOptions),
|
|
15
|
+
...DEFAULT_OPTIONS,
|
|
16
|
+
...origOptions,
|
|
17
|
+
...options,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.initOptions = initOptions;
|
|
21
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;AAAA,0CAAoD;AAGpD,MAAM,eAAe,GAAkC;IACtD,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,QAAQ;IACzB,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,EAAE;IACX,cAAc,EAAE,IAAI;CACpB,CAAC;AAEF,SAAgB,WAAW,CAAC,OAAuC,EAAE,cAAoC,IAAI;IAC5G,OAAO;QACN,GAAG,IAAA,wBAAiB,EAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;AACH,CAAC;AAPD,kCAOC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ComponentAdapter, CommonOptions, ColorTypes, AlertType, VerticalPosition } from "@omegagrid/core";
|
|
2
|
+
import { TreeAdapter } from "@omegagrid/tree";
|
|
3
|
+
export declare enum FormControlType {
|
|
4
|
+
TextInput = "text",
|
|
5
|
+
Button = "button",
|
|
6
|
+
NumericInput = "number",
|
|
7
|
+
DateInput = "date",
|
|
8
|
+
Checkbox = "checkbox",
|
|
9
|
+
Label = "label",
|
|
10
|
+
List = "list",
|
|
11
|
+
ColorInput = "color"
|
|
12
|
+
}
|
|
13
|
+
export type FormControlProperties = {
|
|
14
|
+
/** Row index within form grid */
|
|
15
|
+
row: number;
|
|
16
|
+
/** Column index within form grid */
|
|
17
|
+
col: number;
|
|
18
|
+
/** Unique field identifier */
|
|
19
|
+
key?: string;
|
|
20
|
+
/** Key of bound form control */
|
|
21
|
+
for?: string;
|
|
22
|
+
/** Value validation pattern */
|
|
23
|
+
pattern?: RegExp;
|
|
24
|
+
/** Form control type */
|
|
25
|
+
type?: FormControlType;
|
|
26
|
+
/** Required field */
|
|
27
|
+
required?: boolean;
|
|
28
|
+
/** Readonly control */
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
/** Current control value */
|
|
31
|
+
value?: unknown;
|
|
32
|
+
/** Key of parent element */
|
|
33
|
+
dependsOn?: string;
|
|
34
|
+
/** Component adapter where applicable (eg. TreeSelect) */
|
|
35
|
+
adapter?: ComponentAdapter;
|
|
36
|
+
/** Component item definition */
|
|
37
|
+
content?: unknown;
|
|
38
|
+
/** colspan */
|
|
39
|
+
cs?: number;
|
|
40
|
+
/** rowspan */
|
|
41
|
+
rs?: number;
|
|
42
|
+
/** control-specific options */
|
|
43
|
+
options?: Record<string, unknown>;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
caption?: string;
|
|
46
|
+
};
|
|
47
|
+
export type FormAlert = {
|
|
48
|
+
text: string;
|
|
49
|
+
type: AlertType;
|
|
50
|
+
};
|
|
51
|
+
export type FormRow = {
|
|
52
|
+
height?: number;
|
|
53
|
+
};
|
|
54
|
+
export type FormColumn = {
|
|
55
|
+
width?: number;
|
|
56
|
+
};
|
|
57
|
+
export type FormGridModel = {
|
|
58
|
+
rows: FormRow[];
|
|
59
|
+
columns: FormColumn[];
|
|
60
|
+
};
|
|
61
|
+
export type FormOptions = {
|
|
62
|
+
treeAdapter?: TreeAdapter;
|
|
63
|
+
};
|
|
64
|
+
export type FormContainerOptions = {
|
|
65
|
+
caption?: string;
|
|
66
|
+
buttonsPosition?: VerticalPosition;
|
|
67
|
+
alertsPosition?: VerticalPosition;
|
|
68
|
+
buttons?: FormButtonType[];
|
|
69
|
+
formOptions?: FormOptions;
|
|
70
|
+
closeAfterSave?: boolean;
|
|
71
|
+
} & CommonOptions;
|
|
72
|
+
export type FormSettings = {
|
|
73
|
+
key?: string | number;
|
|
74
|
+
caption?: string;
|
|
75
|
+
treeAdapter?: TreeAdapter;
|
|
76
|
+
controls?: FormControlProperties[];
|
|
77
|
+
columns?: FormColumn[];
|
|
78
|
+
rows?: FormRow[];
|
|
79
|
+
options?: FormOptions;
|
|
80
|
+
};
|
|
81
|
+
export type FormButtonType = "save" | "reset" | "validate" | "storno" | "close";
|
|
82
|
+
export type FormButtonConfig = {
|
|
83
|
+
text: string;
|
|
84
|
+
default?: boolean;
|
|
85
|
+
color?: ColorTypes;
|
|
86
|
+
};
|
|
87
|
+
export type FormAction = FormButtonType;
|
|
88
|
+
export type FormValues = Record<string, unknown>;
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAg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EAAE,UAAU,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormControlType = void 0;
|
|
4
|
+
var FormControlType;
|
|
5
|
+
(function (FormControlType) {
|
|
6
|
+
FormControlType["TextInput"] = "text";
|
|
7
|
+
FormControlType["Button"] = "button";
|
|
8
|
+
FormControlType["NumericInput"] = "number";
|
|
9
|
+
FormControlType["DateInput"] = "date";
|
|
10
|
+
FormControlType["Checkbox"] = "checkbox";
|
|
11
|
+
FormControlType["Label"] = "label";
|
|
12
|
+
FormControlType["List"] = "list";
|
|
13
|
+
FormControlType["ColorInput"] = "color";
|
|
14
|
+
})(FormControlType || (exports.FormControlType = FormControlType = {}));
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAGA,IAAY,eASX;AATD,WAAY,eAAe;IAC1B,qCAAkB,CAAA;IAClB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;IACvB,qCAAkB,CAAA;IAClB,wCAAqB,CAAA;IACrB,kCAAe,CAAA;IACf,gCAAa,CAAA;IACb,uCAAoB,CAAA;AACrB,CAAC,EATW,eAAe,+BAAf,eAAe,QAS1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { ComponentAdapter } from '@omegagrid/core';
|
|
3
|
+
import { FormControlModel, FormModel } from '../../model';
|
|
4
|
+
export declare class ControlEvent<TValue> extends Event {
|
|
5
|
+
readonly model: FormControlModel;
|
|
6
|
+
readonly value: TValue;
|
|
7
|
+
constructor(type: string, model: FormControlModel, value: TValue);
|
|
8
|
+
}
|
|
9
|
+
export interface IControl<TValue = unknown, TAdapter extends ComponentAdapter = null> extends HTMLElement {
|
|
10
|
+
model: FormControlModel;
|
|
11
|
+
adapter: TAdapter;
|
|
12
|
+
value: TValue;
|
|
13
|
+
reset(): void;
|
|
14
|
+
validate(): void;
|
|
15
|
+
get isValid(): boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class BaseControl<TValue = unknown, TAdapter extends ComponentAdapter = null> extends LitElement implements IControl<TValue, TAdapter> {
|
|
18
|
+
static styles: import("lit").CSSResult[];
|
|
19
|
+
model: FormControlModel;
|
|
20
|
+
formModel: FormModel;
|
|
21
|
+
adapter: TAdapter;
|
|
22
|
+
value: TValue;
|
|
23
|
+
required: boolean;
|
|
24
|
+
protected updateValue(value: TValue, dispatchEvent?: boolean): void;
|
|
25
|
+
willUpdate(changedProps: Map<PropertyKey, unknown>): void;
|
|
26
|
+
reset(): void;
|
|
27
|
+
validate(): void;
|
|
28
|
+
get isValid(): boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=baseControl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseControl.d.ts","sourceRoot":"","sources":["../../../src/ui/controls/baseControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D,qBAAa,YAAY,CAAC,MAAM,CAAE,SAAQ,KAAK;aAG7B,KAAK,EAAE,gBAAgB;aACvB,KAAK,EAAE,MAAM;gBAF7B,IAAI,EAAE,MAAM,EACI,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,MAAM;CAI9B;AAED,MAAM,WAAW,QAAQ,CAAC,MAAM,GAAG,OAAO,EAAE,QAAQ,SAAS,gBAAgB,GAAG,IAAI,CAAE,SAAQ,WAAW;IACxG,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,IAAK,IAAI,CAAC;IAClB,IAAI,OAAO,IAAK,OAAO,CAAC;CACxB;AAED,8BAAsB,WAAW,CAAC,MAAM,GAAG,OAAO,EAAE,QAAQ,SAAS,gBAAgB,GAAG,IAAI,CAC3F,SAAQ,UAAW,YAAW,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAExD,MAAM,CAAC,MAAM,4BAYV;IAGH,KAAK,EAAE,gBAAgB,CAAC;IAGxB,SAAS,EAAE,SAAS,CAAC;IAGrB,OAAO,EAAE,QAAQ,CAAC;IAGlB,KAAK,EAAE,MAAM,CAAQ;IAGrB,QAAQ,UAAS;IAEjB,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,UAAO;IAQzD,UAAU,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI;IASzD,KAAK;IAIL,QAAQ;IASR,IAAI,OAAO,YAA2C;CAEtD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BaseControl = exports.ControlEvent = void 0;
|
|
10
|
+
const lit_1 = require("lit");
|
|
11
|
+
const decorators_js_1 = require("lit/decorators.js");
|
|
12
|
+
class ControlEvent extends Event {
|
|
13
|
+
constructor(type, model, value) {
|
|
14
|
+
super(type, { bubbles: true, cancelable: true, composed: true });
|
|
15
|
+
this.model = model;
|
|
16
|
+
this.value = value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ControlEvent = ControlEvent;
|
|
20
|
+
class BaseControl extends lit_1.LitElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.value = null;
|
|
24
|
+
this.required = false;
|
|
25
|
+
}
|
|
26
|
+
updateValue(value, dispatchEvent = true) {
|
|
27
|
+
this.value = value;
|
|
28
|
+
this.validate();
|
|
29
|
+
if (dispatchEvent) {
|
|
30
|
+
this.dispatchEvent(new ControlEvent('change', this.model, value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
willUpdate(changedProps) {
|
|
34
|
+
if (changedProps.has('model')) {
|
|
35
|
+
if (this.value === null) {
|
|
36
|
+
this.value = this.model.props.value;
|
|
37
|
+
}
|
|
38
|
+
this.required = this.model.props.required;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
reset() {
|
|
42
|
+
this.updateValue(this.model.props.value);
|
|
43
|
+
}
|
|
44
|
+
validate() {
|
|
45
|
+
if (!this.model)
|
|
46
|
+
return;
|
|
47
|
+
if (this.required && (this.value == null || this.value === '')) {
|
|
48
|
+
this.model.errors = ['this field is required'];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.model.errors = [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
get isValid() { return this.model.errors.length == 0; }
|
|
55
|
+
}
|
|
56
|
+
exports.BaseControl = BaseControl;
|
|
57
|
+
BaseControl.styles = [(0, lit_1.css) `
|
|
58
|
+
:host {
|
|
59
|
+
display: block;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
* {
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([required]) {
|
|
67
|
+
border: 2px solid var(--accent-color);
|
|
68
|
+
}
|
|
69
|
+
`];
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
72
|
+
], BaseControl.prototype, "model", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
75
|
+
], BaseControl.prototype, "formModel", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
78
|
+
], BaseControl.prototype, "adapter", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
81
|
+
], BaseControl.prototype, "value", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, decorators_js_1.property)({ type: Boolean, reflect: true })
|
|
84
|
+
], BaseControl.prototype, "required", void 0);
|
|
85
|
+
//# sourceMappingURL=baseControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseControl.js","sourceRoot":"","sources":["../../../src/ui/controls/baseControl.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6BAAsC;AACtC,qDAA6C;AAI7C,MAAa,YAAqB,SAAQ,KAAK;IAC9C,YACC,IAAY,EACI,KAAuB,EACvB,KAAa;QAE7B,KAAK,CAAC,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QAH/C,UAAK,GAAL,KAAK,CAAkB;QACvB,UAAK,GAAL,KAAK,CAAQ;IAG9B,CAAC;CACD;AARD,oCAQC;AAWD,MAAsB,WACrB,SAAQ,gBAAU;IADnB;;QA2BC,UAAK,GAAW,IAAI,CAAC;QAGrB,aAAQ,GAAG,KAAK,CAAC;IAkClB,CAAC;IAhC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AAA,SAAG,EAAA;;;;;;;;;;;;EAYnB,CAAC,AAZW,CAYV;AAGH;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0CACD;AAGxB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACJ;AAGrB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACP;AAGlB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0CACJ;AAGrB;IADC,IAAA,wBAAQ,EAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CACxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button as CoreButton } from "@omegagrid/core";
|
|
2
|
+
import { FormControlModel } from "../../model";
|
|
3
|
+
import { IControl } from "./baseControl";
|
|
4
|
+
export declare class FormButton extends CoreButton implements IControl<string> {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
model: FormControlModel;
|
|
7
|
+
adapter: null;
|
|
8
|
+
value: string;
|
|
9
|
+
constructor();
|
|
10
|
+
protected updateValue(value: string, dispatchEvent?: boolean): void;
|
|
11
|
+
willUpdate(changedProps: Map<PropertyKey, unknown>): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
validate(): void;
|
|
14
|
+
get isValid(): boolean;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/ui/controls/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEvD,qBAEa,UAAW,SAAQ,UAAW,YAAW,QAAQ,CAAC,MAAM,CAAC;IAErE,MAAM,CAAC,MAAM,4BAKV;IAGH,KAAK,EAAE,gBAAgB,CAAC;IAGxB,OAAO,EAAE,IAAI,CAAC;IAGd,KAAK,EAAE,MAAM,CAAQ;;IAUrB,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,UAAO;IASzD,UAAU,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI;IASzD,KAAK;IAIL,QAAQ;IAIR,IAAI,OAAO,YAA4C;CAEvD"}
|