-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arch): move && simplify component form field
- Loading branch information
Showing
66 changed files
with
248 additions
and
283 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
packages-new/components/form-field/documentation/specifications/spec.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
* [**Interfaces**](#interfaces) | ||
* [**Classes**](#classes) | ||
* [**Type alias**](#type-alias) | ||
* [**Variables**](#variables) | ||
|
||
## Interfaces | ||
|
||
### OdsFormFieldAttributes | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`error`** | _string_ | | | Indicates if the Form Field shows error or not| | ||
|**`flex`** | _boolean_ | | | Indicates if the Form Field is full width or not: see component principles| | ||
|
||
## Classes | ||
|
||
### OdsFormFieldController | ||
_common controller logic for cmpnt component used by the different implementations._ | ||
_it contains all the glue between framework implementation and the third party service._ | ||
|
||
|
||
## Type alias | ||
|
||
### OdsFormField | ||
|
||
interface description of all implementation of `ods-form-field`. | ||
each implementation must have defined events, methods, attributes | ||
and one controller for the common behavior logic | ||
|
||
> - `OdsComponentGenericMethods` | ||
> - `OdsComponentGenericEvents` | ||
### OdsFormFieldAttributes | ||
|
||
> _Based on `OdsComponentAttributes`_ | ||
### OdsFormFieldEvents | ||
|
||
> _Based on `OdsComponentEvents`_ | ||
### OdsFormFieldMethods | ||
|
||
> _Based on `OdsComponentMethods`_ | ||
## Variables | ||
|
||
### odsFormFieldDefaultAttributes | ||
`OdsFormFieldAttributes` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
.../form-field/specifications-form-field.mdx → ...cifications/specifications-form-field.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
...-new/components/form-field/src/components/osds-form-field/constants/default-attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { OdsFormFieldAttribute } from '../interfaces/attributes'; | ||
|
||
const DEFAULT_ATTRIBUTE: OdsFormFieldAttribute = Object.freeze({ | ||
error: '', | ||
inline: false, | ||
}); | ||
|
||
export { | ||
DEFAULT_ATTRIBUTE, | ||
}; |
10 changes: 6 additions & 4 deletions
10
...s/form-field/ods-form-field-attributes.ts → .../osds-form-field/interfaces/attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { OdsComponentAttributes } from '../ods-component-attributes'; | ||
|
||
export interface OdsFormFieldAttributes extends OdsComponentAttributes { | ||
interface OdsFormFieldAttribute { | ||
/** | ||
* Indicates if the Form Field shows error or not | ||
*/ | ||
error?: string; | ||
/** | ||
* Indicates if the Form Field is full width or not: see component principles | ||
*/ | ||
flex?: boolean; | ||
inline?: boolean; | ||
} | ||
|
||
export { | ||
OdsFormFieldAttribute, | ||
}; |
21 changes: 8 additions & 13 deletions
21
...m-field/osds-form-field.e2e.screenshot.ts → ...m-field/osds-form-field.e2e.screenshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages-new/components/form-field/src/components/osds-form-field/osds-form-field.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import type { SpecPage } from '@stencil/core/testing'; | ||
import type { OdsFormFieldAttribute } from './interfaces/attributes'; | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str, odsUnitTestAttribute } from '@ovhcloud/ods-common-testing'; | ||
import { DEFAULT_ATTRIBUTE } from './constants/default-attributes'; | ||
import { OsdsFormField } from './osds-form-field'; | ||
|
||
describe('spec:osds-form-field', () => { | ||
let page: SpecPage; | ||
let root: HTMLElement | undefined; | ||
let instance: OsdsFormField; | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
async function setup({ attributes = {} }: { attributes?: Partial<OdsFormFieldAttribute> } = {}) { | ||
const stringAttributes = odsComponentAttributes2StringAttributes<OdsFormFieldAttribute>(attributes, DEFAULT_ATTRIBUTE); | ||
|
||
page = await newSpecPage({ | ||
components: [OsdsFormField], | ||
html: `<osds-form-field ${odsStringAttributes2Str(stringAttributes)}>My FormField</osds-form-field>`, | ||
}); | ||
|
||
root = page.root; | ||
instance = page.rootInstance; | ||
} | ||
|
||
it('should render', async () => { | ||
await setup({}); | ||
expect(root?.shadowRoot).toBeTruthy(); | ||
expect(instance).toBeTruthy(); | ||
}); | ||
|
||
describe('attributes', () => { | ||
const config = { | ||
instance: () => instance, | ||
page: () => page, | ||
root: () => page.root, | ||
wait: () => page.waitForChanges(), | ||
}; | ||
|
||
describe('error', () => { | ||
odsUnitTestAttribute<OdsFormFieldAttribute, 'error'>({ | ||
name: 'error', | ||
defaultValue: DEFAULT_ATTRIBUTE.error, | ||
newValue: '', | ||
value: 'There was an error with your message', | ||
setup: (value) => setup({ attributes: { ['error']: value } }), | ||
...config, | ||
}); | ||
}); | ||
|
||
describe('inline', () => { | ||
odsUnitTestAttribute<OdsFormFieldAttribute, 'inline'>({ | ||
name: 'inline', | ||
defaultValue: DEFAULT_ATTRIBUTE.inline, | ||
newValue: false, | ||
value: true, | ||
setup: (value) => setup({ attributes: { ['inline']: value } }), | ||
...config, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages-new/components/form-field/src/components/osds-form-field/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type { OdsFormFieldAttribute } from './interfaces/attributes'; | ||
export { OsdsFormField } from './osds-form-field'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...-field/src/docs/osds-form-field/usage.mdx → ...-field/src/docs/osds-form-field/usage.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.