Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update (TypeScript integration, dependency upgrades, API refactor) #130

Merged
merged 69 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
7b081f6
chore: rename README
oriondean Jul 30, 2018
6957bad
feat: add tsconfig
oriondean Jul 30, 2018
dd26d37
chore: update license year
oriondean Jul 30, 2018
2258358
ts
oriondean Aug 23, 2018
e992097
ts2
oriondean Aug 23, 2018
e887587
feature: remove unused imports
oriondean Nov 26, 2018
bd8e12a
feature: upgrade typescript to 3.1.6
oriondean Nov 26, 2018
f931524
feature: update rawToFormatted to expect rawValue as number
oriondean Nov 26, 2018
bb2b0f5
feature: update root finput class
oriondean Nov 26, 2018
b717feb
chore: remove unused argument
oriondean Nov 26, 2018
5609502
feature: ignore rollup plugin cache
oriondean Nov 27, 2018
21ba4a0
feature: use es2015 module when compiling TS
oriondean Nov 27, 2018
975729e
feature: add rollup configuration
oriondean Nov 27, 2018
ae7885e
feature: replace budo with rollup and http-server
oriondean Nov 27, 2018
5d7212a
fix: remove references to this
oriondean Nov 27, 2018
e09d058
fix: infinite loop
oriondean Nov 27, 2018
1ee2b2f
feature: add minificiation of dist build
oriondean Nov 27, 2018
dfe3cab
feature: upgrade dependencies
oriondean Nov 27, 2018
a03485e
fix: remove nested test
oriondean Nov 27, 2018
21523b1
fix: reintroduce babel presets to allow tests to function
oriondean Nov 27, 2018
9aa8c64
feature: added silent serve mode
oriondean Nov 27, 2018
f118761
feature: update baseUrl to match http-server default
oriondean Nov 27, 2018
3990c5f
fix: actually make http-server be silent
oriondean Nov 27, 2018
cf61ce0
feature: add in cross-env to enable development build
oriondean Nov 27, 2018
48342fa
fix: issue with traversal tests
oriondean Nov 27, 2018
2311a86
fix: lowercase key info so shortcuts work
oriondean Nov 27, 2018
996a63a
fix: quick compile error any cast
oriondean Nov 27, 2018
5d9ead7
feature: enable typescript strict mode
oriondean Nov 27, 2018
9a0db4b
feature: add is_js typings
oriondean Nov 27, 2018
eef7071
feature: tightened up typescript typings
oriondean Nov 27, 2018
fe00ad1
feature: integrate tslint
oriondean Nov 28, 2018
37fb895
feature: update to latest babel
oriondean Nov 28, 2018
8aa1235
feature: add husky pre-commit hook
oriondean Nov 28, 2018
ea3f738
fix: various refactors that caused regressions
oriondean Nov 28, 2018
dcdc8df
feature: update example finput usage
oriondean Nov 28, 2018
64ff1fb
feature: tidied typings
oriondean Nov 29, 2018
49fc1de
feature: update browserstack access key
oriondean Nov 29, 2018
0a180b2
feature: update build command travis invokes
oriondean Nov 29, 2018
01721aa
feature: use stringify to compare arrays rather than weak reference e…
oriondean Nov 29, 2018
2acdbc7
feature: build library before test runs
oriondean Nov 29, 2018
73f5836
feature: update keyboard shortcut modifier tests
oriondean Nov 29, 2018
1ace1a4
fix: run build:prod task before webdriver start
oriondean Nov 29, 2018
ca5aa37
feature: tidy TODOs
oriondean Nov 29, 2018
db03bcb
feature: revert browserstack username access_key updates
oriondean Nov 29, 2018
8abadf2
feature: refactor external API of finput slightly to allow setting of…
oriondean Nov 29, 2018
c4b36d0
feature: update README to reflect various changes to API and developm…
oriondean Nov 29, 2018
68dcd34
Merge remote-tracking branch 'sl/master' into typescript-integration
oriondean Nov 29, 2018
2179c02
feature: ignore all files beginning with dot
oriondean Dec 6, 2018
6af2b13
fix: README .ts / .js typo
oriondean Dec 6, 2018
ec424b7
feature: remove callback suffix
oriondean Dec 6, 2018
a147927
feature: update rollup to use UMD module format
oriondean Apr 1, 2019
fdf0702
chore: remove whitespace
oriondean Apr 1, 2019
b07f3b3
fix: issue with setting raw value of 0 returning empty string
oriondean Apr 1, 2019
03f80a2
feature: update test task names
oriondean Apr 1, 2019
a953aba
fix: setRawValue tests
oriondean Apr 1, 2019
0c32d68
chore: add optional to package lock
oriondean Apr 1, 2019
b66c1c5
feature: Add public destroy method
oriondean Apr 1, 2019
e33d183
fix: issue with using EventListenerObject type in later versions of t…
oriondean Apr 2, 2019
265e107
feature: update dependencies
oriondean Apr 2, 2019
3bd5a7b
fix: issues with running e2e tests with chromedriver needing chrome 74
oriondean Apr 2, 2019
e3310d6
fix: e2e tests not running when calling test task
oriondean Apr 2, 2019
0117ba1
fix: remove silent serve task
oriondean Apr 2, 2019
69593b1
fix: don't cache node_modules and run test rather than test:ci task
oriondean Apr 2, 2019
82627f3
feature: use headless chrome for e2e tests
oriondean Apr 2, 2019
01ff47b
fix: disable extensions and sandboxing
oriondean Apr 2, 2019
fe55866
fix: add chrome to travis
oriondean Apr 2, 2019
01f5f47
feature: update node version to ensure compatibility with semantic-re…
oriondean Apr 4, 2019
e779752
feat: update license year
oriondean Apr 4, 2019
267f55d
feat: remove automated deployment attempt
oriondean Apr 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
node_modules/
.idea/
.git
npm-debug.log
selenium-debug.log
config.json
dist/
lib/
.DS_Store
.*
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.1.4
8.3.0
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
notifications:
email:
on_success: change
on_failure: always
before_script:
- npm prune
script:
- npm run build
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run test:ci; fi
after_success:
- npm run semantic-release
- npm run build:prod
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run test; fi
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"
Expand All @@ -23,6 +18,7 @@ addons:
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4kmw8P/4jLiZBIRY5INGWSBAlnCypdJk3bPvAckEz8ABoV5wChDyL+oPwJn9yogpQmlw3MEO40G4nMIJ41nkpmcazh+Hi40FFPuKHSxVEMj992SuCJ4CxKjTWg8eqCdLdgcaz3TRIGBzcWU3MHMIaX8Xm33prYtEOPkQhoyMJNcuwYh4sT/9w/CPu4MlVGv/iFnZ+Rt4c7Xe8jBma3YG8AVEyu0IYYzgW8PzjXr6He3pWHgIkIaB5b5jW2KPWUAOkEDB6vmDx6KHRWNCYW/6L0TfO3+AxiS3bfIIL7WOLCkc+WtUMSjvd01gQJMw=
chrome: stable
env:
global:
- secure: gZkLEExtLiDXbkZ6a2kKl6BdFYzTztpnF/TMse0dVPZgC46dOZ3i0KClGo6Q5OhAVu2+97qbW8ye9iWmShF23nyJUqItqfi5wqn5ytzEoN10eEE/jcxn2BwBtpAB4VuiIh2RtPjWK4q4ji7r18O8jub3H64pofTr6tX1b069a/N4huw9xebGjcAcb8CP9hv184QDKEVT/ksr8F9f1/3n2uB7dofeERZTw6fmxTsHcGJ9y1irI/A9xp4HVXOshQWE6A/h5kJHuRdjyd6y/yNts2hC6vpbcWDr1eWKwYUALkQoYciB7RZaJOHKLMKWeDqfMEm5gx92Q1hLENfu4HQBWZglR7qhpZVWhk6Tfaj3p2OfM1IolQNG8mhk7GUslqsGo5YX6gQttls4OieXFPft0qMZnFReTcasXgIlBmhYQn7CqgxTtSqhP8vmIB90zHwb8Ou8FnsF1oae5vl93+UuhUjJsT62Zlw5f8VmUQODu7wkQYtb39tfzgX7KKtuTI5D+RmI73CpZaTrQMeQVl22Dpp0N1+7MKBxj4unCpi3J1xPoNWfXlgP+uld9L6bYUgfxXustPTSfZ6RuJpI4wahzBY6SksLwBtGLo47xrKi3W22BhP0oi+jPQmqacOH627HD62mD8PFfLB00TlqwtLP/vjAgPGOR8af7vYVzkN0lRA=
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Scott Logic
Copyright (c) 2019 Scott Logic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
47 changes: 23 additions & 24 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ See an example finput [here](http://scottlogic.github.io/finput)
`npm install finput`

#### Initialise input
To initialise the finput, simply pass the element and any options into the finput constructor.
The function returned is the cleanup function which removes all the added finput listeners from the input,
making it act like the default browser input once again.

```javascript
var destroy = finput(element, options);
destroy(); // Stops finput behaviour
```
To initialise the finput, simply pass the element and any options into the finput constructor.
An object is returned which allows you to interact with the finput API.

Options
-----
Expand Down Expand Up @@ -81,16 +75,16 @@ Default: `{
An object mapping of shortcuts that the user can use to quickly enter common values.
E.g. with the default shortcuts, typing `k` will multiply the number value by 1000

##### invalidKeyCallback
##### onInvalidKey
Type: `Function(e)`
Default: `() => {}`
A callback function that is fired everytime a invalid key is pressed.
A callback function that is fired each time a invalid key is pressed.
the callback is called with the [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) object that was raised on keydown.

##### onFocusinCallback
##### onFocus
Type: `Function(e)`
Default: `undefined`
A callback function that is fired everytime the input is brought into focus.
A callback function that is fired each time the input is focussed.
the callback is called with the `Event` object.

the function used needs to return an object with a start and end value, a numerical
Expand All @@ -103,21 +97,21 @@ representation of the postions to select.

setting both values to 0 or failing to return both values will disable selecting functionality

Accessing input value
---------------------

The formatted value (the inputs value) and raw numeric value can be access directly on the dom element
as follows:
**Formatted value** - `element.value` _(the normal input value)_
**Raw numeric value** - `element.rawValue`

API
--------------------

The following functions are exposed on the `element`:
The following properties are exposed on the returned finput instance:

##### options
Retrieves the options on the input

##### rawValue
Retrieves the raw value of the input (numerical)

#### value
Retrieves the formatted value of the input (string)

##### getOptions
Gets a copy of the options from the input
The following functions are exposed on the returned finput instance:

##### setOptions
Sets the options on the input
Expand All @@ -143,6 +137,9 @@ Sets the value, fully formatted, for the input
##### setRawValue
Sets and formats the value for the input
* `val` New value to set

##### removeListeners
Removes finputs listeners from the provided element, returning it to a standard native control

Developing
----------
Expand All @@ -159,7 +156,9 @@ Run dev server:

Building Library
----------------
- `npm run build`
- `npm run build:dev` - Builds a development friendly version of the application
- `npm run build:prod` - Builds a minified version of the application
- `npm run compile` - Compiles typescript dependency-free version of library

Running tests
-------------
Expand Down
32 changes: 0 additions & 32 deletions finput.d.ts

This file was deleted.

38 changes: 38 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ActionType, Key, Range } from "./src/constants";
import ValueHistory from "./src/valueHistory";

interface IState {
value: string;
caretStart: number;
caretEnd: number;
valid: boolean;
}

interface IKeyInfo {
name: string;
modifiers: string[];
}

interface IOptions {
thousands: string;
decimal: string;
fixed: boolean;
range: Range;
scale: number;
shortcuts: { [shortcut: string]: number };
onInvalidKey: (event: KeyboardEvent) => void;
onFocus: (event: FocusEvent) => ISelection | void;
}

interface IAction {
type: ActionType;
names: string[];
modifiers?: Key[];
}

interface ISelection {
start: number;
end: number;
}

type ActionHandler = (currentState: IState, keyInfo: IKeyInfo, options: IOptions, history: ValueHistory) => IState;
21 changes: 11 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,30 @@ <h2>Native Controls</h2>
finput(finputDefault, {});

finput(finputCustomFocus, {
onFocusinCallback: function () { return { start: 0, end: 1 }; }
onFocus: function () { return { start: 0, end: 1 }; }
});

finput(finputInvalidKeyCallback, {
invalidKeyCallback: function (info) { console.log('invalid keypress', info); }
onInvalidKey: function (info) { console.log('invalid keypress', info); }
});

finput(finputReversedDelimiters, {
thousands: '.',
decimal: ','
});

finput(finputSwitchOptions, {});
var finputSwitchOptionsInstance = finput(finputSwitchOptions, {});

finputSwitchOptionsButton.onclick = function () {
var options = finputSwitchOptions.getOptions();
var tempThousands = options.thousands;
options.thousands = options.decimal;
options.decimal = tempThousands;
var tempThousands = finputSwitchOptionsInstance.options.thousands;
var tempRawValue = finputSwitchOptionsInstance.rawValue;

finputSwitchOptions.setOptions(options);
// redraw
finputSwitchOptions.setRawValue(finputSwitchOptions.rawValue);

finputSwitchOptionsInstance.setOptions({
thousands: finputSwitchOptionsInstance.options.decimal,
decimal: tempThousands
});
finputSwitchOptionsInstance.setRawValue(tempRawValue);
}
</script>

Expand Down
Loading