Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/feat(codebase): Refactor API-compatible. Added many features. (
#57) * refactor/feat(codebase): Total refactor and API-compatible. Added many features. In this refactor we have added new features too: [x] Created a better organization of files and types. [x] Created a way of communicate with our children components [x] An API more robust and open [x] Created external events to get changes from inputs (onChange, onBlur, onChange, onEnter, onEscape, onFocus, etc.). These events are shotcuts to angular-native events (ex. keypress.enter/keypress.escape), so you can bind those. However, this shorcuts provide you of state of input when this one changed. [x] New options to configure when an event is triggered (ex. hidebuttons, cancelOnEscape, saveOnEnter, saveOnBlur, etc.) [x] An internal service shared between root and child component. (this feature will be more use in the future, so it is WIP) [x] Interfaces to provide a specifig config to inputs (specific intellisense to input text, input select, etc.) How works The new API to communicate the root component with their children? When a child component change its state, this one triggers an event and the root component get it. Using this system of internal events we can provide external events (to the client) and trigger events such as onChange, onFocus, on Blur, etc. A change of state can be: change of value, edit mode or disabled mode. Closes #38 #47 #30 #21 * fix(InlineEditorComponent): When onSave emits the ngModel isn't refreshed yet. This fixs that, first is setted and then is emited * refactor(InlineEditor): Use a subscriptions dictionary instead of property per subscription. Add destroy() in InlineService * fix(InlineEditorComponent): Fix config overwritten order. By order of preference 1. Config from attributes ([type], [pattern], etc.) 2. Config from [config] property 3. Default config (`defaultConfig`) * feature(InlineEditorComponent): Add onlyValue option This option is useful when you only want/need the value of input and not the complete event ( { event: Event, state: InlineState} ). It's `true` by default Then, when onlyValue is enabled the external events emit an any value (it can be string, boolean, number, object, etc.) * feature(InlineEditor): If an input is empty or not is handler by itself This fix a problem with `InputSelectComponent`, it showed `empty` when the option was not found, but `empty` property of its state was `false`. It happened because the value was not empty (`"test"`, `1`), but there was not any option with that value. Now the inputs handle when they are or are not empty implementing the `isEmpty` method of `InputBase`, by default an input is empty if its value is an empty string (`""`) , `undefined` or `null`. And I have simplified the way how the `InputSelectComponent` searched the option selected. * fix(paths/names): Fixed paths and names. Better imports paths. We have "normalized" some names like InlineError -> InlineError, InlineEvent -> InlineEditorEvent, etc. Added `config.ts` that exports the input's config interfaces. Then, you can import them from 'ng2-inline-editor' or 'ng2-inline-editor/configs', interfaces like InputTextConfig, InputNumberConfig, etc. * chore(yarn): Add yarn.lock to VCS and dependencies updated
- Loading branch information