Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

TypeScript #28

Merged
merged 50 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b5e3aa3
Create tsconfig.json
aminya Mar 14, 2020
c9e3006
Add dev deps + Add Eslint/TsLint + prettier config
aminya Mar 15, 2020
06f8a4e
Add scripts
aminya Mar 29, 2020
361cbb9
js-to-ts-converter .
aminya May 8, 2020
9642dda
import instead of require for atom/fuzzaldrin
aminya Mar 29, 2020
ef4bba6
global not needed for atom
aminya Mar 29, 2020
db55db1
SelectListView members + SelectListProperties interface
aminya Mar 29, 2020
c3bf30e
etch type temporarily
aminya Mar 29, 2020
7a6850a
TODO: fix redundant returns in methods
aminya Mar 29, 2020
89a593a
this.items = props.items + TODO
aminya Mar 29, 2020
fc980cd
CommandEvent
aminya Mar 29, 2020
84471b7
itemIndex: number
aminya Mar 29, 2020
fb0e265
updateComponent?: boolean
aminya Mar 29, 2020
3aae572
fuzzyFilter types
aminya Mar 29, 2020
bc68e9c
const score
aminya Mar 29, 2020
def1ee7
props types
aminya Mar 29, 2020
b969819
MouseEvent
aminya Mar 29, 2020
fae6b9a
export update
aminya Jan 4, 2021
9ee731d
JSDoc style doc strings
aminya Jan 4, 2021
533da24
Rename src_src to src - output in lib
aminya May 8, 2020
b2722a9
separate file for SelectListProperties
aminya May 8, 2020
93718c2
Remoev tslint, eslint, prettier
aminya Jan 4, 2021
beb3f3f
Update tsconfig
aminya Jan 4, 2021
a37549c
Break on tsc errors
aminya Jan 5, 2021
af6f304
Wrap long docs
aminya Jan 5, 2021
e5df058
Use // for normal comments
aminya Jan 5, 2021
5abb4f0
Factor out ListItemViewProps
aminya Jan 5, 2021
4b5e63b
Update and move tsconfig
aminya Jan 5, 2021
eaf175d
Move and change import/require
aminya Jan 5, 2021
31f3665
Add dev script
aminya Jan 5, 2021
72f9d01
Remove unused locals
aminya Jan 5, 2021
43b1d75
Move strict tsconfig
aminya Jan 5, 2021
cf1cac7
noImplicitAny and strict
aminya Jan 5, 2021
d5d3736
Fix fuzzaldrin types
aminya Jan 5, 2021
cc81360
Use in instead of hasOwnProperty
aminya Jan 5, 2021
231df2c
Replace the deprecated scrollIntoViewIfNeeded
aminya Jan 5, 2021
fd8902f
Downgrade sinon
aminya Jan 5, 2021
c021cc9
Bump typescript deps
aminya Jan 5, 2021
cdf3129
Use ES5 export style (to prevent exports.default)
aminya Jan 5, 2021
8818ab0
Depend on strict for noImplicitAny and noImplicitThis
aminya Jan 6, 2021
e2bff3a
Make skipCommandsRegistration optional
aminya Jan 6, 2021
f43e920
remove space
aminya Jan 6, 2021
246ff18
Make items private
aminya Jan 6, 2021
0e9dc1f
Revert "Replace the deprecated scrollIntoViewIfNeeded"
aminya Jan 6, 2021
80c3e14
Add ts-ignore for scrollIntoViewIfNeeded
aminya Jan 6, 2021
180f224
Remove initial assignment to this.items
aminya Jan 7, 2021
414607f
update the docstring for items
aminya Jan 7, 2021
3c11348
Fix the type for this.refs.items.children
aminya Jan 7, 2021
b4a58f7
Remove {} from the default value for props
aminya Jan 7, 2021
b07cbec
remove space
aminya Jan 8, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.DS_Store
npm-debug.log
package-lock.json
lib
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@
"name": "atom-select-list",
"version": "0.7.2",
"description": "A general-purpose select list for use in Atom packages",
"main": "./src/select-list-view.js",
"main": "lib/select-list-view.js",
"files": [
"lib/**/*"
],
"scripts": {
"test": "atom --test test"
"dev": "npm run typescript -- --watch",
"typescript": "tsc -p ./tsconfig.json",
"build": "npm run typescript",
"test": "atom --test test",
"prepare": "npm run build"
},
"author": "",
"license": "MIT",
"atomTestRunner": "atom-mocha-test-runner",
"devDependencies": {
"atom-mocha-test-runner": "^0.3.0",
"sinon": "^2.1.0"
"atom-mocha-test-runner": "^1.2.0",
"sinon": "^2",
"typescript": "^4.1.3",
"@types/atom": "^1.40.5",
"@types/fuzzaldrin": "^2.1.3"
},
"dependencies": {
"etch": "^0.12.6",
"etch": "^0.14.0",
"fuzzaldrin": "^2.1.0"
},
"repository": {
Expand Down
88 changes: 88 additions & 0 deletions src/select-list-properties.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { EtchElement } from './select-list-view' // TODO: etch types

export interface SelectListProperties {
/** an array containing the objects you want to show in the select list. */
items: Array<object | string>

/**
* a function that is called whenever an item needs to be displayed.
*
* `options: { selected: boolean, index: number, visible: boolean }`
*
* - `selected`: indicating whether item is selected or not.
* - `index`: item's index.
* - `visible`: indicating whether item is visible in viewport or not. Unless initiallyVisibleItemCount was given,
this value is always true.
*/
elementForItem: (
item: object | string,
options: { selected: boolean; index: number; visible: boolean }
) => EtchElement // TODO: HTMLElement

/** (Optional) the number of maximum items that are shown. */
maxResults?: number

/** (Optional) a function that allows to decide which items to show whenever the query changes.
By default, it uses fuzzaldrin to filter results. */
filter?: (items: Array<object | string>, query: string) => Array<object>

/** (Optional) when filter is not provided, this function will be called to retrieve a string property on each item,
and that will be used to filter them. */
filterKeyForItem?: (item: object | string) => string

/** (Optional) a function that allows to apply a transformation to the user query and whose return value
will be used to filter items. */
filterQuery?: (query: string) => string

/** (Optional) a string that will replace the contents of the query editor. */
query?: string

/** (Optional) a boolean indicating whether the query text should be selected or not. */
selectQuery?: boolean

/** (Optional) a function that allows to change the order in which items are shown. */
order?: (item1: object | string, item2: object | string) => number

/** (Optional) a string shown when the list is empty. */
emptyMessage?: string

/** (Optional) a string that needs to be set when you want to notify the user that an error occurred. */
errorMessage?: string

/** (Optional) a string that needs to be set when you want to provide some information to the user. */
infoMessage?: string

/** (Optional) a string that needs to be set when you are loading items in the background. */
loadingMessage?: string

/** (Optional) a string or number that needs to be set when the progress status changes
(e.g. a percentage showing how many items have been loaded so far). */
loadingBadge?: string | number

/** (Optional) an array of strings that will be added as class names to the items element. */
itemsClassList?: Array<string>

/** (Optional) the index of the item to initially select and automatically select after query changes; defaults to 0. */
initialSelectionIndex?: number

/** (Optional) a function that is called when the query changes. */
didChangeQuery?: (query: string) => void

/** (Optional) a function that is called when the selected item changes. */
didChangeSelection?: (item: object | string) => void

/** (Optional) a function that is called when the user clicks or presses Enter on an item. */
didConfirmSelection?: (item: object | string) => void

/** (Optional) a function that is called when the user presses Enter but the list is empty. */
didConfirmEmptySelection?: () => void

/** (Optional) a function that is called when the user presses Esc or the list loses focus. */
didCancelSelection?: () => void

/** (Optional) When this options was provided, SelectList observe visibility of items in viewport, visibility state is
passed as visible option to elementForItem. This is mainly used to skip heavy computation for invisible items. */
initiallyVisibleItemCount?: number

skipCommandsRegistration?: boolean
}
Loading