Skip to content

Commit

Permalink
refactor(checkbox): move checkbox to packages-new
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 authored and dpellier committed Aug 10, 2023
1 parent b0c1366 commit 7e7eff3
Show file tree
Hide file tree
Showing 87 changed files with 980 additions and 1,111 deletions.
File renamed without changes.
File renamed without changes.
228 changes: 228 additions & 0 deletions packages-new/components/checkbox/documentation/specifications/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
* [**Interfaces**](#interfaces)
* [**Types**](#types)
* [**Classes**](#classes)
* [**Type alias**](#type-alias)
* [**Variables**](#variables)

## Interfaces

### OdsCheckboxAttributes
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`afterSave`** | `OdsCheckboxAttributeCbk` | | | afterSave input allows to set a function that returns a promise.It is called after each time an update was performed and allowing to manage pessimistic update strategy|
|**`ariaLabel`** | `null` \| `string` | ✴️ | | The corresponding aria-label describing its content|
|**`ariaLabelledby`** | _string_ | | | The id to an external description|
|**`beforeSave`** | `OdsCheckboxAttributeCbk` | | | beforeSave input allows to set a function that returns a promise.It is called before each time an update will be performed and allowing to manage pessimistic update strategy|
|**`checked`** | _boolean_ | ✴️ | | The checked status of the checkbox|
|**`disabled`** | _boolean_ | ✴️ | | indicate if the checkbox is entirely disabled.it means no interactions (hover, click, focus, etc)|
|**`hasFocus`** | _boolean_ | ✴️ | | is the checkbox is currently focused|
|**`label`** | _string_ | | | The corresponding label|
|**`name`** | _string_ | | | name used for the input element.useful for browser and posting forms|
|**`save`** | `OdsCheckboxAttributeCbk` | | | save input allows to set a function that returns a promise.It is called before each time an update is performed and allowing to manage pessimistic update strategy.the checked state will be updated just after the call.|
|**`updating`** | _boolean_ | ✴️ | | update status indicating if the checked state is being modified.`updating` will be `true` until `beforeSave` or `save` are processed.it is used in `pessimistic` update|
|**`value`** | _string_ | ✴️ | | Its corresponding value|

### OdsCheckboxBehavior
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checkboxableComponent`** | `null` \| `undefined` | ✴️ | | component that have to be managed by the checkbox smart component.for instance: a tile, a toggle|
|**`hostElement`** | `Host` | ✴️ | | reference to the host element of the component|
|**`inputEl`** | `HTMLInputElement` | | | reference to the native input element inside the component.could be undefined if the reference is not yet filled.|
|**`tabindex`** | _number_ | ✴️ | | current tab index parameter.this will be ignored in case of component disabled.must be `0` by default|
|**`afterInit`** | _void_ | ✴️ | | method executed after initialization of component(`componentDidLoad` with stenciljs for instance).this method has to call OdsCheckboxController.afterInit|
|**`emitBlur`** | _void_ | ✴️ | | when a blur is triggered, this method emit the event|
|**`emitChecked`** | _void_ | ✴️ | | emit an event when the checked state changed|
|**`emitFocus`** | _void_ | ✴️ | | when a focus is triggered, this method emit the event|
|**`emitUpdating`** | _void_ | ✴️ | | emit an event when the checked state is being updated|
|**`getTabIndex`** | _number_ | ✴️ | | get the current tab index.this method has to call OdsCheckboxController.getTabIndex|
|**`handleToggleByClick`** | _void_ | ✴️ | | handle toggle check on click MouseEvent.this method has to call OdsCheckboxController.handleToggleByClick|
|**`handleToggleByKeyEvent`** | _void_ | ✴️ | | handle toggle check on keyboardEvent.this method has to call OdsCheckboxController.handleToggleByKeyEvent|
|**`onBlur`** | _void_ | ✴️ | | process the blur of the component.this method has to call OdsCheckboxController.onBlur|
|**`onFocus`** | _void_ | ✴️ | | process the focus on the component.the method should be call when focus event is triggered on component (by click, keyboard)this method has to call OdsCheckboxController.onFocus|
|**`propagateCheckedToChild`** | _void_ | ✴️ | | propagate checked attribute to the <checkboxed> component (like tile or toggle).this method should be call on `checked` attribute changed.this method has to call OdsCheckboxController.propagateCheckedToChild|
|**`propagateDisabledToChild`** | _void_ | ✴️ | | propagate disabled attribute to the <checkboxed> component (like tile or toggle).this method should be call on `disabled` attribute changed.this method has to call OdsCheckboxController.propagateDisabledToChild|
|**`propagateHasFocusToChild`** | _void_ | ✴️ | | propagate hasFocus attribute to the <checkboxed> component (like tile or toggle).this method should be call on `hasFocus` attribute changed.this method has to call OdsCheckboxController.propagateHasFocusToChild|

### OdsCheckboxButtonAttributes
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checked`** | _boolean_ | | | The checked status of the checkbox button|
|**`checking`** | _boolean_ | | | |
|**`color`** | `OdsThemeColorIntent` | | | The color theme|
|**`disabled`** | _boolean_ | | | Prevent the user from clicking on the radio button|
|**`hasFocus`** | _boolean_ | | | Display a focus style (only if interactive)|
|**`indeterminate`** | _boolean_ | | | The indeterminate status of the checkbox button (override checked status)|
|**`interactive`** | _boolean_ | | | Display an interactive style when clicking or hovering the radio button|
|**`size`** | `OdsCheckboxButtonSize` | | | Size of the radio button|

### OdsCheckboxCheckedChangeEventDetail
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checked`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |

### OdsCheckboxEvents
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsBlur`** | `OdsCheckboxFocusChangeEventDetail` | ✴️ | | Event triggered on checkbox blur|
|**`odsCheckedChange`** | `OdsCheckboxCheckedChangeEventDetail` | ✴️ | | the checked state changed|
|**`odsFocus`** | `OdsCheckboxFocusChangeEventDetail` | ✴️ | | Event triggered on checkbox focus|
|**`odsUpdatingChange`** | `OdsCheckboxUpdatingChangeEventDetail` | ✴️ | | the checked state is being changed|

### OdsCheckboxFocusChangeEventDetail
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`focus`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |

### OdsCheckboxMethods
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`setFocus`** | _void_ | ✴️ | | programmatically set the focus on the checkbox.this method has to call OdsCheckboxController.setFocus|
|**`setTabindex`** | _void_ | ✴️ | | set the tab index.this method has to call OdsCheckboxController.setTabindex|

### OdsCheckboxUpdatingChangeEventDetail
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`updating`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |

### OdsCheckboxable
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checked`** | _boolean_ | ✴️ | | |
|**`checking`** | _boolean_ | ✴️ | | is in state of awaiting the checked change|
|**`disabled`** | _boolean_ | ✴️ | | |
|**`hasFocus`** | _boolean_ | ✴️ | | |

## Types

### OdsCheckboxButtonSize
| |
|:---:|
| `md` |
| `sm` |

## Classes

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

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


### OdsCheckboxButtonMock

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

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

> **getTabIndex**() => _unknown_

> **handleToggleByClick**() => _unknown_

> **handleToggleByKeyEvent**() => _unknown_

> **onBlur**() => _unknown_

> **onFocus**() => _unknown_

> **propagateCheckedToChild**() => _unknown_

> **propagateDisabledToChild**() => _unknown_

> **propagateHasFocusToChild**() => _unknown_

> **setFocus**() => _unknown_

> **setTabindex**() => _unknown_

> **toggleCheck**() => _unknown_


### OdsCheckboxUtils
#### Methods
> **isCheckedOnClick**() => _unknown_


## Type alias

### OdsCheckbox

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

> - `OdsComponentGenericMethods`
> - `OdsComponentGenericEvents`
### OdsCheckboxAttributeCbk

### OdsCheckboxButton

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

> - `OdsComponentGenericMethods`
> - `OdsComponentGenericEvents`
### OdsCheckboxAttributes

> _Based on `OdsComponentAttributes`_
### OdsCheckboxButtonAttributes

> _Based on `OdsComponentAttributes`_
### OdsCheckboxButtonEvents

> _Based on `OdsComponentEvents`_
### OdsCheckboxButtonMethods

> _Based on `OdsComponentMethods`_
### OdsCheckboxEvents

> _Based on `OdsComponentEvents`_
### OdsCheckboxFocusChangeEventDetail

> _Based on `OdsFocusChangeEventDetail`_
### OdsCheckboxMethods

> _Based on `OdsComponentMethods`_
## Variables

### odsCheckboxButtonDefaultAttributes
`OdsCheckboxButtonAttributes`

### odsCheckboxButtonDefaultAttributesDoc
`OdsCheckboxButtonAttributes`

### odsCheckboxDefaultAttributes
`OdsCheckboxAttributes`
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SpecsCheckboxContents from '@ovhcloud/ods-specifications/components/checkbox/specifications-checkbox-contents.mdx';
import SpecsCheckboxIntegration from '@ovhcloud/ods-specifications/components/checkbox/specifications-checkbox-integration.mdx';
import SpecsCheckboxTests from '@ovhcloud/ods-specifications/components/checkbox/specifications-checkbox-tests.mdx';
import Specs from '@ovhcloud/ods-core/src/components/checkbox/docs/spec.md';
import {Description} from '@storybook/addon-docs';
import SpecsCheckboxContents from './specifications-checkbox-contents.mdx';
import SpecsCheckboxIntegration from './specifications-checkbox-integration.mdx';
import SpecsCheckboxTests from './specifications-checkbox-tests.mdx';
import Specs from './spec.md';
import { Description } from '@storybook/addon-docs';

## Description

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
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);

/**
* synchronous config for jest.
*
* example with async config :
* ```typescript
* export default async (): Promise<Config.InitialOptions> => {
* return {
* verbose: true,
* };
* };
* ```
*/
// @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
17 changes: 17 additions & 0 deletions packages-new/components/checkbox/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* setup jest file executed for each test and in the test environment
* @see https://jestjs.io/fr/docs/configuration#setupfiles-array
*/

// set a mocked configured config for ODS
// config can be changed on the fly later in tests

const setupConfig: any = { config: { logging: { active: false } } };
/**
* mock the window for jest testing.
* very useful with stencil in order to manage the MockedWindow of stencil.
* warning: when using `window` with stencil e2e test, each time window is called, a new MockedWindow is created.
* it can lead to misunderstanding, so it is recommended to use this in every e2e tests.
* @param setupConfig- - window's ods config
*/

Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "@ovhcloud/ods-stencil-checkbox",
"name": "@ovhcloud/ods-component-checkbox",
"version": "15.0.1",
"private": true,
"description": "Checkbox wrapper component",
"description": "ODS Checkbox 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/interface.d.ts",
"types": "dist/types/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"scripts": {
Expand All @@ -36,9 +35,13 @@
"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-component-tile": "^15.0.1",
"@ovhcloud/ods-theming": "^15.0.1"
},
"devDependencies": {
"@ovhcloud/ods-stencil-component-dev": "^15.0.1"
"@ovhcloud/ods-common-testing": "^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-checkbox-react",
"name": "@ovhcloud/ods-component-checkbox-react",
"version": "15.0.1",
"private": true,
"description": "React specific wrapper for ods",
Expand All @@ -20,19 +20,13 @@
"dist/"
],
"dependencies": {
"@ovhcloud/ods-stencil-cart": "^15.0.1",
"tslib": "*"
"@ovhcloud/ods-component-checkbox": "^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,20 @@
import type { OdsCheckboxAttribute } from '../interfaces/attributes';

const DEFAULT_ATTRIBUTE: OdsCheckboxAttribute = Object.freeze({
afterSave: undefined,
ariaLabel: '',
ariaLabelledby: undefined,
beforeSave: undefined,
checked: false,
hasFocus: false,
disabled: false,
label: undefined,
name: '',
save: undefined,
updating: false,
value: '',
});

export {
DEFAULT_ATTRIBUTE,
};
Loading

0 comments on commit 7e7eff3

Please sign in to comment.