Skip to content

Commit

Permalink
feat(arch): move && simplify component quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
dpellier committed Aug 22, 2023
1 parent cb861fc commit 2d0ac2b
Show file tree
Hide file tree
Showing 86 changed files with 1,032 additions and 428 deletions.
1 change: 1 addition & 0 deletions packages-new/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@ovhcloud/ods-component-message": "^15.0.1",
"@ovhcloud/ods-component-pagination": "^15.0.1",
"@ovhcloud/ods-component-password": "^15.0.1",
"@ovhcloud/ods-component-quantity": "^15.0.1",
"@ovhcloud/ods-component-select": "^15.0.1",
"@ovhcloud/ods-component-skeleton": "^15.0.1",
"@ovhcloud/ods-component-spinner": "^15.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dist/
custom-elements/
custom-elements-bundle/
www/
loader/
docs-api
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
* [**Interfaces**](#interfaces)
* [**Classes**](#classes)
* [**Type alias**](#type-alias)
* [**Variables**](#variables)

## Interfaces

### OdsQuantityAttributes
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`disabled`** | _boolean_ | | | Quantity is disabled or not|

### OdsQuantityBehavior
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`el`** | `HTMLElement` | ✴️ | | reference to the host element.|
|**`input`** | `null` \| `HTMLInputElement` \| `undefined` | ✴️ | | reference to the osds-input or native input element inside the component.could be null if the reference is not yet filled.|
|**`minus`** | `null` \| `HTMLSlotElement` | ✴️ | | reference to the minus slot inside the component.could be null if the reference is not yet filled.|
|**`plus`** | `null` \| `HTMLSlotElement` | ✴️ | | reference to the plus slot inside the component.could be null if the reference is not yet filled.|
|**`afterInit`** | _void_ | ✴️ | | after init component functionshould be called after component loadsshould process input value change|
|**`afterRender`** | _void_ | ✴️ | | after render component functionshould be called after component rendershould init inputshould init slots|
|**`onDestroy`** | _void_ | ✴️ | | after init component functionshould be called after component loadsshould clear event listeners|

## Classes

### OdsQuantityController
_common controller logic for chip component used by the different implementations._
_it contains all the glue between framework implementation and the third party service._

#### Methods
> **clearEventListeners**() => _unknown_

> **initInput**() => _unknown_

> **initSlots**() => _unknown_

> **minusClickHandler**() => _unknown_

> **plusClickHandler**() => _unknown_

> **processInputValueChange**() => _unknown_

> **setDisabledOnChildren**() => _unknown_


### OdsQuantityMock
_Mocked generic implementation that represents an `OdsQuantity`._
_it allows to test the controller with a stub implementation._


## Type alias

### OdsQuantity

interface description of all implementation of `ods-quantity`.
each implementation must have defined events, methods, attributes
and one controller for the common behavior logic

> - `OdsComponentGenericMethods`
> - `OdsComponentGenericEvents`
### OdsQuantityEvents

### OdsQuantityMethods

### OdsQuantityAttributes

> _Based on `OdsComponentAttributes`_
## Variables

### odsQuantityDefaultAttributes
`OdsQuantityAttributes`
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Description} from '@storybook/addon-docs';
import Specs from '@ovhcloud/ods-core/src/components/quantity/docs/spec.md';
import SpecsQuantityContents from '@ovhcloud/ods-specifications/components/quantity/specifications-quantity-contents.mdx';
import SpecsQuantityIntegration from '@ovhcloud/ods-specifications/components/quantity/specifications-quantity-integration.mdx';
import SpecsQuantityTests from '@ovhcloud/ods-specifications/components/quantity/specifications-quantity-tests.mdx';
import Specs from './spec.md';
import SpecsQuantityContents from './specifications-quantity-contents.mdx';
import SpecsQuantityIntegration from './specifications-quantity-integration.mdx';
import SpecsQuantityTests from './specifications-quantity-tests.mdx';

## Description
The Quantity aims to show and modify a desired quantity.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Config } from '@jest/types';
import { OdsGetJestConfig } from '@ovhcloud/ods-testing';
import { OdsGetJestConfig } from '@ovhcloud/ods-common-testing';

const args = process.argv.slice(2);

Expand All @@ -15,9 +15,10 @@ const args = process.argv.slice(2);
* };
* ```
*/
// @ts-ignore until dependencies are fixed to one unique version of @jest/types
const config: Config.InitialOptions = {
...OdsGetJestConfig({
basePath: '<rootDir>/../../../..',
basePath: '<rootDir>/../../..',
args
}),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @see https://jestjs.io/fr/docs/configuration#setupfiles-array
*/

import { odsMockWindow } from '@ovhcloud/ods-testing/src/jest/ods-mock-window';
import { odsMockWindow } from '@ovhcloud/ods-common-testing/src/jest/ods-mock-window';

// set a mocked configured config for ODS
// config can be changed on the fly later in tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "@ovhcloud/ods-stencil-quantity",
"name": "@ovhcloud/ods-component-quantity",
"version": "15.0.1",
"private": true,
"description": "Quantity component",
"description": "ODS Quantity component",
"author": "OVH SAS",
"license": "Apache-2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
"es2015": "dist/esm/index.js",
"es2017": "dist/esm/index.js",
"types": "dist/types/components.d.ts",
"types": "dist/types/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"scripts": {
Expand All @@ -35,11 +34,15 @@
"test:e2e:ci:screenshot:update": "stencil test --config stencil.config.ts --e2e --ci --screenshot --update-screenshot --passWithNoTests"
},
"dependencies": {
"@ovhcloud/ods-stencil-component": "^15.0.1"
"@ovhcloud/ods-common-core": "^15.0.1",
"@ovhcloud/ods-common-stencil": "^15.0.1",
"@ovhcloud/ods-theming": "^15.0.1"
},
"devDependencies": {
"@ovhcloud/ods-common-testing": "^15.0.1",
"@ovhcloud/ods-component-button": "^15.0.1",
"@ovhcloud/ods-component-icon": "^15.0.1",
"@ovhcloud/ods-component-input": "^15.0.1",
"@ovhcloud/ods-stencil-component-dev": "^15.0.1"
"@ovhcloud/ods-stencil-dev": "^15.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ovhcloud/ods-stencil-quantity-react",
"name": "@ovhcloud/ods-component-quantity-react",
"version": "15.0.1",
"private": true,
"description": "React specific wrapper for ods",
Expand All @@ -20,19 +20,13 @@
"dist/"
],
"dependencies": {
"@ovhcloud/ods-stencil-quantity": "^15.0.1",
"tslib": "*"
"@ovhcloud/ods-component-quantity": "^15.0.1"
},
"peerDependencies": {
"react": ">=16.8.6",
"react-dom": ">=16.8.6"
},
"devDependencies": {
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"react": "16.14.0",
"react-dom": "16.14.0",
"rimraf": "^3.0.2",
"typescript": "4.7.4"
"@ovhcloud/ods-react-dev": "^15.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { OdsQuantityAttribute } from '../interfaces/attributes';

const DEFAULT_ATTRIBUTE: OdsQuantityAttribute = Object.freeze({
disabled: false
});

export {
DEFAULT_ATTRIBUTE,
};
Loading

0 comments on commit 2d0ac2b

Please sign in to comment.