@omegagrid/form 0.6.135 → 0.6.136

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.
@@ -19,7 +19,9 @@ export declare abstract class BaseControl<TValue = unknown, TAdapter extends Com
19
19
  model: FormControlModel;
20
20
  formModel: FormModel;
21
21
  adapter: TAdapter;
22
- value: TValue;
22
+ private _value;
23
+ get value(): TValue;
24
+ set value(value: TValue);
23
25
  required: boolean;
24
26
  protected updateValue(value: TValue, dispatchEvent?: boolean): void;
25
27
  willUpdate(changedProps: Map<PropertyKey, unknown>): void;
@@ -1 +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,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AAG,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;IAElB,OAAO,CAAC,MAAM,CAAgB;IAC9B,IACI,KAAK,IACQ,MAAM,CADY;IACnC,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAMtB;IAGD,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"}
@@ -16,11 +16,19 @@ export class ControlEvent extends Event {
16
16
  export class BaseControl extends LitElement {
17
17
  constructor() {
18
18
  super(...arguments);
19
- this.value = null;
19
+ this._value = null;
20
20
  this.required = false;
21
21
  }
22
+ get value() { return this._value; }
23
+ set value(value) {
24
+ const oldValue = this._value;
25
+ this._value = value;
26
+ if (oldValue !== value) {
27
+ this.requestUpdate('value', oldValue);
28
+ }
29
+ }
22
30
  updateValue(value, dispatchEvent = true) {
23
- this.value = value;
31
+ this._value = value;
24
32
  this.validate();
25
33
  if (dispatchEvent) {
26
34
  this.dispatchEvent(new ControlEvent('change', this.model, value));
@@ -73,7 +81,7 @@ __decorate([
73
81
  ], BaseControl.prototype, "adapter", void 0);
74
82
  __decorate([
75
83
  property({ type: Object })
76
- ], BaseControl.prototype, "value", void 0);
84
+ ], BaseControl.prototype, "value", null);
77
85
  __decorate([
78
86
  property({ type: Boolean, reflect: true })
79
87
  ], BaseControl.prototype, "required", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"baseControl.js","sourceRoot":"","sources":["../../../src/ui/controls/baseControl.ts"],"names":[],"mappings":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,KAAe,CAAC,CAAC;IACpD,CAAC;IAED,QAAQ;QACP,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QACxB,CAAC;IACF,CAAC;IAED,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAA,CAAC,CAAC;;AA3D/C,kBAAM,GAAG,CAAC,GAAG,CAAA;;;;;;;;;;;;EAYnB,CAAC,AAZW,CAYV;AAGH;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0CACD;AAGxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACJ;AAGrB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACP;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0CACJ;AAGrB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CACxB","sourcesContent":["import { css, LitElement } from 'lit';\nimport { property } from \"lit/decorators.js\";\nimport { ComponentAdapter } from '@omegagrid/core';\nimport { FormControlModel, FormModel } from '../../model';\n\nexport class ControlEvent<TValue> extends Event {\n\tconstructor(\n\t\ttype: string,\n\t\tpublic readonly model: FormControlModel,\n\t\tpublic readonly value: TValue\n\t) {\n\t\tsuper(type, {bubbles: true, cancelable: true, composed: true});\n\t}\n}\n\nexport interface IControl<TValue = unknown, TAdapter extends ComponentAdapter = null> extends HTMLElement {\n\tmodel: FormControlModel;\n\tadapter: TAdapter;\n\tvalue: TValue;\n\treset(): void;\n\tvalidate() : void;\n\tget isValid() : boolean;\n}\n\nexport abstract class BaseControl<TValue = unknown, TAdapter extends ComponentAdapter = null> \n\textends LitElement implements IControl<TValue, TAdapter> {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\n\t\t* {\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t:host([required]) {\n\t\t\tborder: 2px solid var(--og-accent-color);\n\t\t}\n\t`];\n\n\t@property({type: Object})\n\tmodel: FormControlModel;\n\n\t@property({type: Object})\n\tformModel: FormModel;\n\n\t@property({type: Object})\n\tadapter: TAdapter;\n\n\t@property({type: Object})\n\tvalue: TValue = null;\n\n\t@property({type: Boolean, reflect: true})\n\trequired = false;\n\n\tprotected updateValue(value: TValue, dispatchEvent = true) {\n\t\tthis.value = value;\n\t\tthis.validate();\n\t\tif (dispatchEvent) {\n\t\t\tthis.dispatchEvent(new ControlEvent<TValue>('change', this.model, value));\n\t\t}\n\t}\n\n\twillUpdate(changedProps: Map<PropertyKey, unknown>): void {\n\t\tif (changedProps.has('model')) {\n\t\t\tif (this.value === null) {\n\t\t\t\tthis.value = this.model.props.value as TValue;\n\t\t\t}\n\t\t\tthis.required = this.model.props.required;\n\t\t}\n\t}\n\n\treset() {\n\t\tthis.updateValue(this.model.props.value as TValue);\n\t}\n\n\tvalidate() {\n\t\tif (!this.model) return;\n\t\tif (this.required && (this.value == null || this.value === '')) {\n\t\t\tthis.model.errors = ['this field is required'];\n\t\t} else {\n\t\t\tthis.model.errors = [];\n\t\t}\n\t}\n\n\tget isValid() { return this.model.errors.length == 0 }\n\t\n}"]}
1
+ {"version":3,"file":"baseControl.js","sourceRoot":"","sources":["../../../src/ui/controls/baseControl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,O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entAdapter } from '@omegagrid/core';\nimport { FormControlModel, FormModel } from '../../model';\n\nexport class ControlEvent<TValue> extends Event {\n\tconstructor(\n\t\ttype: string,\n\t\tpublic readonly model: FormControlModel,\n\t\tpublic readonly value: TValue\n\t) {\n\t\tsuper(type, {bubbles: true, cancelable: true, composed: true});\n\t}\n}\n\nexport interface IControl<TValue = unknown, TAdapter extends ComponentAdapter = null> extends HTMLElement {\n\tmodel: FormControlModel;\n\tadapter: TAdapter;\n\tvalue: TValue;\n\treset(): void;\n\tvalidate() : void;\n\tget isValid() : boolean;\n}\n\nexport abstract class BaseControl<TValue = unknown, TAdapter extends ComponentAdapter = null> \n\textends LitElement implements IControl<TValue, TAdapter> {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\n\t\t* {\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t:host([required]) {\n\t\t\tborder: 2px solid var(--og-accent-color);\n\t\t}\n\t`];\n\n\t@property({type: Object})\n\tmodel: FormControlModel;\n\n\t@property({type: Object})\n\tformModel: FormModel;\n\n\t@property({type: Object})\n\tadapter: TAdapter;\n\n\tprivate _value: TValue = null;\n\t@property({type: Object})\n\tget value() { return this._value; }\n\tset value(value: TValue) {\n\t\tconst oldValue = this._value;\n\t\tthis._value = value;\n\t\tif (oldValue !== value) {\n\t\t\tthis.requestUpdate('value', oldValue);\n\t\t}\n\t}\n\t\n\t@property({type: Boolean, reflect: true})\n\trequired = false;\n\n\tprotected updateValue(value: TValue, dispatchEvent = true) {\n\t\tthis._value = value;\n\t\tthis.validate();\n\t\tif (dispatchEvent) {\n\t\t\tthis.dispatchEvent(new ControlEvent<TValue>('change', this.model, value));\n\t\t}\n\t}\n\n\twillUpdate(changedProps: Map<PropertyKey, unknown>): void {\n\t\tif (changedProps.has('model')) {\n\t\t\tif (this.value === null) {\n\t\t\t\tthis.value = this.model.props.value as TValue;\n\t\t\t}\n\t\t\tthis.required = this.model.props.required;\n\t\t}\n\t}\n\n\treset() {\n\t\tthis.updateValue(this.model.props.value as TValue);\n\t}\n\n\tvalidate() {\n\t\tif (!this.model) return;\n\t\tif (this.required && (this.value == null || this.value === '')) {\n\t\t\tthis.model.errors = ['this field is required'];\n\t\t} else {\n\t\t\tthis.model.errors = [];\n\t\t}\n\t}\n\n\tget isValid() { return this.model.errors.length == 0 }\n\t\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/form",
3
- "version": "0.6.135",
3
+ "version": "0.6.136",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Universal form component",
6
6
  "main": "./dist/index.js",
@@ -27,10 +27,10 @@
27
27
  "_prepublish": "yarn test && yarn lint"
28
28
  },
29
29
  "dependencies": {
30
- "@omegagrid/calendar": "^0.6.135",
31
- "@omegagrid/core": "^0.6.135",
32
- "@omegagrid/localize": "^0.6.135",
33
- "@omegagrid/tree": "^0.6.135",
30
+ "@omegagrid/calendar": "^0.6.136",
31
+ "@omegagrid/core": "^0.6.136",
32
+ "@omegagrid/localize": "^0.6.136",
33
+ "@omegagrid/tree": "^0.6.136",
34
34
  "lit": "^3.1.1",
35
35
  "lit-html": "^3.1.1",
36
36
  "ts-debounce": "^4.0.0"