@lion/field
Advanced tools
Comparing version 0.9.2 to 0.10.0
@@ -6,2 +6,21 @@ # Change Log | ||
# [0.10.0](https://github.com/ing-bank/lion/compare/@lion/field@0.9.2...@lion/field@0.10.0) (2020-02-20) | ||
### Bug Fixes | ||
* by default, serialize undefined values as '' ([583a182](https://github.com/ing-bank/lion/commit/583a1820d616d2801f2701ac92d623e777534c1b)) | ||
* rearrange/cleanup mixin duties ([cb7120e](https://github.com/ing-bank/lion/commit/cb7120e3a59f02e7e87f00c4d281e47ca8d33ea8)) | ||
* removed FieldCustomMixin ([f44d8aa](https://github.com/ing-bank/lion/commit/f44d8aa26ae7124d8dcb251e1f66ab9beae71050)) | ||
* **field:** interaction states initialized after registration ready ([d6829ef](https://github.com/ing-bank/lion/commit/d6829ef6199a31e4b2ab1e97dd2ccce354043145)) | ||
### Features | ||
* api normalisation formElements and values ([9b905c4](https://github.com/ing-bank/lion/commit/9b905c492a0c0d2226cc1d75c73e2e70dc97815a)) | ||
## [0.9.2](https://github.com/ing-bank/lion/compare/@lion/field@0.9.1...@lion/field@0.9.2) (2020-02-19) | ||
@@ -8,0 +27,0 @@ |
@@ -104,8 +104,2 @@ # Formatting and parsing | ||
### FieldCustomMixin | ||
When creating your own custom input, please use `FieldCustomMixin` as a basis for this. | ||
Concrete examples can be found at [`<lion-input-date>`](https://github.com/ing-bank/lion/blob/master/packages/input-date) and | ||
[`<lion-input-amount>`](https://github.com/ing-bank/lion/blob/master/packages/input-amount). | ||
## Flow diagram | ||
@@ -112,0 +106,0 @@ |
@@ -1,2 +0,1 @@ | ||
export { FieldCustomMixin } from './src/FieldCustomMixin.js'; | ||
export { FocusMixin } from './src/FocusMixin.js'; | ||
@@ -7,4 +6,5 @@ export { FormatMixin } from './src/FormatMixin.js'; | ||
export { LionField } from './src/LionField.js'; | ||
export { FormRegisteringMixin } from './src/FormRegisteringMixin.js'; | ||
export { FormRegistrarMixin } from './src/FormRegistrarMixin.js'; | ||
export { FormRegistrarPortalMixin } from './src/FormRegistrarPortalMixin.js'; | ||
export { FormRegisteringMixin } from './src/registration/FormRegisteringMixin.js'; | ||
export { FormRegistrarMixin } from './src/registration/FormRegistrarMixin.js'; | ||
export { FormRegistrarPortalMixin } from './src/registration/FormRegistrarPortalMixin.js'; | ||
export { FormControlsCollection } from './src/registration/FormControlsCollection.js'; |
{ | ||
"name": "@lion/field", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"description": "Fields are the most fundamental building block of the Form System", | ||
@@ -47,3 +47,3 @@ "author": "ing-bank", | ||
}, | ||
"gitHead": "417b37a61695128619c6040a6523819c51f51651" | ||
"gitHead": "a5afaaeb272d9eb4c1f40ab6c742b25a86d3c422" | ||
} |
@@ -167,3 +167,3 @@ /* eslint-disable class-methods-use-this */ | ||
serializer(v) { | ||
return v; | ||
return v !== undefined ? v : ''; | ||
} | ||
@@ -179,3 +179,3 @@ | ||
deserializer(v) { | ||
return v; | ||
return v === undefined ? '' : v; | ||
} | ||
@@ -182,0 +182,0 @@ |
import { html, css, nothing, dedupeMixin, SlotMixin } from '@lion/core'; | ||
import { FormRegisteringMixin } from './FormRegisteringMixin.js'; | ||
import { FormRegisteringMixin } from './registration/FormRegisteringMixin.js'; | ||
import { getAriaElementsInRightDomOrder } from './utils/getAriaElementsInRightDomOrder.js'; | ||
@@ -32,6 +32,13 @@ | ||
/** | ||
* The name the element will be registered on to the .formElements collection | ||
* of the parent. | ||
*/ | ||
name: { | ||
type: String, | ||
reflect: true, | ||
}, | ||
/** | ||
* When no light dom defined and prop set | ||
*/ | ||
label: String, | ||
/** | ||
@@ -44,3 +51,2 @@ * When no light dom defined and prop set | ||
}, | ||
/** | ||
@@ -50,3 +56,2 @@ * Contains all elements that should end up in aria-labelledby of `._inputNode` | ||
_ariaLabelledNodes: Array, | ||
/** | ||
@@ -79,2 +84,10 @@ * Contains all elements that should end up in aria-describedby of `._inputNode` | ||
set fieldName(value) { | ||
this.__fieldName = value; | ||
} | ||
get fieldName() { | ||
return this.__fieldName || this.label || this.name; | ||
} | ||
get slots() { | ||
@@ -153,5 +166,2 @@ return { | ||
/** | ||
* Public methods | ||
*/ | ||
_enhanceLightDomClasses() { | ||
@@ -158,0 +168,0 @@ if (this._inputNode) { |
@@ -27,5 +27,4 @@ import { dedupeMixin } from '@lion/core'; | ||
}, | ||
/** | ||
* True when user has typed in something in the input field. | ||
* True when user has changed the value of the field. | ||
*/ | ||
@@ -36,3 +35,2 @@ dirty: { | ||
}, | ||
/** | ||
@@ -117,5 +115,4 @@ * True when user has left non-empty field or input is prefilled. | ||
initInteractionState() { | ||
if (this.constructor._isPrefilled(this.modelValue)) { | ||
this.prefilled = true; | ||
} | ||
this.dirty = false; | ||
this.prefilled = this.constructor._isPrefilled(this.modelValue); | ||
} | ||
@@ -122,0 +119,0 @@ |
@@ -40,6 +40,2 @@ import { SlotMixin, LitElement } from '@lion/core'; | ||
}, | ||
name: { | ||
type: String, | ||
reflect: true, | ||
}, | ||
autocomplete: { | ||
@@ -221,10 +217,2 @@ type: String, | ||
} | ||
set fieldName(value) { | ||
this.__fieldName = value; | ||
} | ||
get fieldName() { | ||
return this.__fieldName || this.label || this.name; | ||
} | ||
} |
@@ -55,3 +55,3 @@ import { expect, fixture, html, aTimeout, defineCE, unsafeStatic } from '@open-wc/testing'; | ||
describe(`FormatMixin ${cfg.suffix ? `(${cfg.suffix})` : ''}`, async () => { | ||
describe('FormatMixin', async () => { | ||
let elem; | ||
@@ -58,0 +58,0 @@ let nonFormat; |
import { LitElement } from '@lion/core'; | ||
import { defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing'; | ||
import sinon from 'sinon'; | ||
import { FormRegisteringMixin } from '../src/FormRegisteringMixin.js'; | ||
import { formRegistrarManager } from '../src/formRegistrarManager.js'; | ||
import { FormRegistrarMixin } from '../src/FormRegistrarMixin.js'; | ||
import { FormRegistrarPortalMixin } from '../src/FormRegistrarPortalMixin.js'; | ||
import { FormRegisteringMixin } from '../src/registration/FormRegisteringMixin.js'; | ||
import { formRegistrarManager } from '../src/registration/formRegistrarManager.js'; | ||
import { FormRegistrarMixin } from '../src/registration/FormRegistrarMixin.js'; | ||
import { FormRegistrarPortalMixin } from '../src/registration/FormRegistrarPortalMixin.js'; | ||
@@ -12,7 +12,6 @@ export const runRegistrationSuite = customConfig => { | ||
baseElement: HTMLElement, | ||
suffix: null, | ||
...customConfig, | ||
}; | ||
describe(`FormRegistrationMixins${cfg.suffix ? ` (${cfg.suffix})` : ''}`, () => { | ||
describe('FormRegistrationMixins', () => { | ||
let parentTag; | ||
@@ -19,0 +18,0 @@ let childTag; |
@@ -18,7 +18,6 @@ import { | ||
allowedModelValueTypes: [Array, Object, Number, Boolean, String, Date], | ||
suffix: '', | ||
...customConfig, | ||
}; | ||
describe(`InteractionStateMixin ${cfg.suffix ? `(${cfg.suffix})` : ''}`, async () => { | ||
describe(`InteractionStateMixin`, async () => { | ||
let tag; | ||
@@ -178,2 +177,14 @@ before(() => { | ||
it('has a method initInteractionState()', async () => { | ||
const el = await fixture(html`<${tag}></${tag}>`); | ||
el.modelValue = 'Some value'; | ||
expect(el.dirty).to.be.true; | ||
expect(el.touched).to.be.false; | ||
expect(el.prefilled).to.be.false; | ||
el.initInteractionState(); | ||
expect(el.dirty).to.be.false; | ||
expect(el.touched).to.be.false; | ||
expect(el.prefilled).to.be.true; | ||
}); | ||
describe('SubClassers', () => { | ||
@@ -180,0 +191,0 @@ it('can override the `_leaveEvent`', async () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166446
3328
31