Commit Graph

408 Commits

Author SHA1 Message Date
David Wheatley
afbf5f4905
fix: incorrect typings for Modal hide() method (#3180)
* fix: incorrect typings for `hide()`

* fix: swap to arrow calling of hide handler
2021-11-23 22:54:26 +00:00
David Sevilla Martin
aa0b68bc8d
Convert some common classes/utils to TS (#2929)
* Convert common/Session

* Update common/states/AlertManagerState

* Convert common/utils/extractText

Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-11-23 17:51:04 -05:00
David Sevilla Martin
94c4f266e3
feat: remove color validation in appearance admin page & add color indicator (#3140)
* Remove color validation in basics admin page & add color indicator

* Create ColorInput common component

* Revert 'formGroupAttrs' addition

* Rename component CSS classes

* Fix input type in ColorInput from AdminPage#buildSettingComponent

* Rename component to ColorPreviewInput, remove aliases in admin & export in compat

* Remove leftovers from rebase on master

* feat: add global type definition for a vnode element tag

* fix(a11y): add aria roles to color input

* chore: use new type

* chore: format

Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-11-23 21:38:46 +00:00
Sami Mazouz
a203469109
fix: Modal typings complicate inheritance (#3178) 2021-11-23 14:02:14 +01:00
David Wheatley
eaf1b86785
fix(a11y): add focus traps to modals and nav drawer (#3018)
* Add focus trap util

* Add focus trap to Modals

Fixes #2663

* Split tab press into `onTab` handler

* Remove deprecated code

* Use requestAnimationFrame instead of setTimeout

* Reduce code duplication

* Implement focus trap in nav drawer

Fixes #2665

* Hide drawer when window is resized to be bigger

Fixes issue where focus trap would remain on the drawer when it is
just the app header, if the drawer was opened then the window was
made larger.

* Simplify conditional function calls

* Fix modal focus trap

* Remove debug code

* Simplify resize handler conditional statements

* Add info about reasoning of resize handler

* Prefer native JS methods over jQuery

* Update conditional function call to handle `undefined`

* Expose screen sizes as CSS custom properties

* Use `window.matchMedia` rather than resize handler

* Fix spelling error

Co-authored-by: David Sevilla Martin <me@datitisev.me>

* Remove breaking change

Co-authored-by: David Sevilla Martin <me@datitisev.me>
2021-11-21 19:44:31 +00:00
Sami Mazouz
d82ae27231
fix: Post--by-actor not showing when comparing user instances as discussion.user() is not loaded (#3170) 2021-11-19 18:41:13 +01:00
Alexander Skvortsov
390caa51db Fix minor typing error on UserListPage 2021-11-16 15:50:54 -05:00
Alexander Skvortsov
924815b6e1 Extension permission typings, fix glitch with extension permissions grid 2021-11-16 15:49:42 -05:00
Alexander Skvortsov
9b639e09f2 Fix errors on 20X responses with no body
`''` is not json-parsable, so  in that case we return null. This was the behavior prior to bac0e594ee
2021-11-16 13:34:28 -05:00
Ian Morland
c120f28d42
Add priority order to discussion controls (#3165) 2021-11-16 15:04:54 +01:00
Alexander Skvortsov
d72b8b8d8e Fix some typing errors 2021-11-11 19:53:44 -05:00
Garrett Grimm
9b9ca53b81
Add 'Close' & 'Back' aria-label attributes to buttons. (#3161)
* Add aria-label attributes to close buttons in nav, welcome hero, modal close.
* Replace title with aria-label in nav back button.
2021-11-11 15:55:46 -05:00
David Wheatley
cab2e797eb
Rewrite ItemList; update ItemList typings (#3005)
* Improve typings for ItemList

* Add new `.replace()` syntax

* Update JSDoc

* Add missing `T` type

* Fix typo

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>

* Allow choice to not set `itemName` property when calling `toArray`

* Make `ItemList.items` read-only

* Modify `.replace()`; add `.changePriority()`

* Complete rename

* Update JSDoc

* Add `.toObject()` method; deprecate `.items`

* Rewrite `.toArray()` to use Proxy instead of modifying the item content

- Fixes #3030
- Fixes issue where setting `itemName` property could result in errors depending on the object type (e.g. proxies)
- Fixes unneeded duplication of item list
- Add option to disable setting `itemName` property on primitives

* Simplify condition

* Remove debug code

* Make proxying function protected instead of private

* Update a usage of ItemList as an example

* Make `itemName` property read-only

* Use correct capitalisation of `object`

* Invert `toArray` parameter function

* Simplify isEmpty check

* Update ItemList.ts

* Fix `merge()`

* Remove extra JSDoc comment

* Use `._items` directly for merging

* Rename methods: `replace` -> `set`; `changePriority` -> `setPriority`

This more closely matches our existing method names (`get()`)

* Change `items` getter

* Simplify proxying

* Update URL to source function

* Update compat

* Various changes to toObject

* Remove `Item.key`

* Make item content proxy method private

* Enforce merge typings

* Update TSDoc comments to use `{@link}` for references to methods

* Correct references to deprecated `.replace` method

* Throw error when setting content/priority of non-existent items

* Remove intermediary variable

* Update TSDoc block

* Update js/src/@types/global.d.ts

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-11-11 20:01:10 +00:00
Alexander Skvortsov
bac0e594ee
Add typechecks, typescript coverage GH action, fix many type errors (#3136) 2021-11-11 14:17:22 -05:00
David Wheatley
ad2cef70d2
chore: better typings for DiscussionListState (#3132) 2021-11-08 22:33:52 -05:00
David Wheatley
ec730d2615
feat: allow use of any tag in listItems helper (#3147)
* feat: allow use of any tag in `listItems` helper

* fix: fix missing optional chaining

* chore: use more optional chaining

* fix: various typings errors

* chore: replace `Vnode[]` with `Children`
2021-11-08 23:52:47 +00:00
David Sevilla Martin
b90001d98c
Convert extend util to TypeScript (#2928)
* Allow using file extension in core compat imports

Necessary for extend imports to have proper typings as we also have an unrelated extend/index.js file

* Add .ts file extension to extend imports for typings

* Fix changes to proxifyCompat regex breaking non-core import paths

* Move utility types to global types

Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-11-08 16:52:13 -05:00
Alexander Skvortsov
e797276606
Use calculated offset when loading page in PaginatedListState (#3159) 2021-11-08 16:33:07 -05:00
Garrett Grimm
0957cca9e2
Add aria-label attribute to navigation drawer button. (#3157)
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-11-08 13:40:17 -05:00
David Wheatley
8c47b197f0
fix: Component.component argument typings (#3148) 2021-11-04 21:38:50 +00:00
David Wheatley
6eb05cfbad
chore: replace for ... in with Array.reduce (#3149) 2021-11-03 23:21:47 +00:00
David Sevilla Martin
497dccee56
Pass null/falsy values through Model.getIdentifier (#3131)
* Pass null/falsy values through Model.getIdentifier

* Add explicit if-return
2021-11-01 11:16:01 -04:00
Dan Wallis
c44cf42e2c
Deprecate unused evented utility (#3125) 2021-10-31 16:18:44 -04:00
Alexander Skvortsov
cb6405110c
Support, update to webpack 5 (#3135) 2021-10-31 14:21:17 -04:00
David Sevilla Martin
1e595e752a
Add textarea setting type to AdminPage#buildSettingComponent (#3141) 2021-10-30 19:16:21 -04:00
David Sevilla Martin
f260bd7efe
Switch to constructor MIN_SEARCH_LENGTH in Search component (#3130) 2021-10-30 19:13:43 -04:00
David Wheatley
f8232b9c1b
chore: rewrite frontend application files to Typescript (#3006)
* Rename files

* Rewrite common Application to TS

* Improve DefaultResolver typings

* Convert mapRoutes to TS

* Fix incorrect JSDoc type

* Add missing default value

* Add debug button string to localisations

* WIP Forum application TS rewrite

* Use union and intersection to remove property duplication

* Address some review comments

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>

* Address some review comments

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>

* Fix build error

* Address some review comments

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>

* Add `type` import qualifier

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-10-30 23:44:27 +01:00
David Wheatley
7db2d0f697
chore: rewrite ModalManager and state to Typescript (#3007)
* Rewrite ModalManagerState into Typescript

- Fixes `attrs` parameter being marked as required
- Add `isModalOpen` method

* Rewrite ModalManager into Typescript

* Fix incorrect type

* Continue modal rewrite

* Update attr typings

* Fix correctly cast `this.constructor` calls

* Cast to bool

* Don't extend ModalAttrs by Record

* Prevent missing abstract methods in child Modals from bricking frontend

* Add missing `app` import

* Address review comment

Co-authored-by: David Sevilla Martin <6401250+datitisev@users.noreply.github.com>

Co-authored-by: David Sevilla Martin <6401250+datitisev@users.noreply.github.com>
2021-10-31 00:29:10 +02:00
David Wheatley
a0a06973c0
chore: rewrite SubtreeRetainer into Typescript (#3137)
* chore: rewrite SubtreeRetainer in Typescript

* chore: mark attributes as protected
2021-10-31 00:28:30 +02:00
David Sevilla Martin
70588959eb
fix: remove 'typeof' in 'typeof this' from AdminPage#buildSettingComponent params (#3142) 2021-10-30 00:37:41 +02:00
Sami Mazouz
acf16fdf2e
chore: Minor Readme CSS code tidy up (#3138) 2021-10-29 19:31:15 +01:00
Alexander Skvortsov
2000727e94
Better post loading support (#3100)
Needed for https://github.com/flarum/core/issues/3043.

Some posts are loaded dynamically, and won't be immediately available. In this case, we show a loading indicator instead of displaying content. In this PR:

- We redraw post content if loading state has chnaged
- We show a loading indicator while loading
2021-10-29 13:32:30 -04:00
Ian Morland
28ead83b04
Add README documentation to ExtensionPage (#3094)
Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
2021-10-27 21:56:56 -04:00
David Wheatley
e0b6190733
[A11Y] Improve accessibility for discussion reply count on post stream (#3090)
* Add class to remove all UA styles from a button

* Improve classList utilisation

* Simplify JSX

* Use classlist instead of concatenation

* Fix reply count focusable when not acting as a button

* Add SR only class

* Add new reply count translations

* Use cleaner translations

* Remove unused import

* Add missing new line

* Delete Accessibility.less

* Use existing `.visually-hidden` class

* Format

* Fix locale formatting
2021-10-27 22:59:17 +02:00
Alexander Skvortsov
e550b15cea
Bump ICU MessageFormat (#3122)
This uses `Intl.PluralRules` for plural rules, and fixes a security vulnerability allowing JS injection through translation arguments.
2021-10-27 16:41:49 -04:00
David Wheatley
57d91b2d87
Revert "chore: better typings for DiscussionListState"
This reverts commit e9b3d3d313.
2021-10-27 17:17:24 +02:00
David Wheatley
e9b3d3d313
chore: better typings for DiscussionListState 2021-10-27 17:17:01 +02:00
Alexander Skvortsov
2b0d55632e
ExtensionPage: rename "Uninstall" to "Purge" (#3123)
https://i.imgur.com/aOOkqhk.png
2021-10-26 17:32:39 -04:00
Alexander Skvortsov
a661376d16
Catch errors when uploading white avatar (#3119) 2021-10-25 17:34:39 -04:00
Clark Winkelmann
9416b1c150
Fix mail settings select component never being used (#3120) 2021-10-25 01:44:46 -04:00
Alexander Skvortsov
60f0ef0bd5
Handle post rendering errors to avoid bricking (#3061)
Whether it's due to corrupted content, missing tags, caching issues, or other assorted reasons, post content can't be rendered. Currently, this results in an exception that crashes the entire forum and is hard to debug. Instead, we should log the error and show an indicator message that rendering has failed.

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-10-14 14:30:18 -04:00
Sami Mazouz
713d95eb36
fix: import app from common app instead (#3104)
Introduced in #3099
2021-10-14 14:41:22 +01:00
David Sevilla Martin
05121b928a
Lazy draw dropdowns to improve performance (#2925) 2021-10-13 14:55:32 -04:00
Fransiscus Rolanda Malau
0a7e885eab
Add missing autocomplete attributes to input fields (#3088)
* Add missing autocomplete attributes to input fields
* Add autocomplete attributes to password fields
* Attribute should use new-password
2021-10-13 14:53:35 -04:00
Braunson Yager
2a86c25297
Added ES6 local support for formatNumber helper as per #2951 (#3099) 2021-10-13 14:48:37 -04:00
Alexander Skvortsov
1c2465b2da Support filter params in discussion list state
https://github.com/flarum/core/pull/3068 accidentially broke the user discussions page, as up until this commit, `DiscussionListState`didn't accept any filter params.
2021-10-06 23:30:32 -04:00
Alexander Skvortsov
a6717ee981 Remove .html on all docs urls
Now that Flarum docs have been moved to docusaurus, URLs no longer end with `.html`.

Closes https://github.com/flarum/core/issues/3092
2021-10-05 10:13:19 -04:00
Sami Mazouz
e2f01c040b
fix: Anchors should not have type="button" (#3086) 2021-09-29 11:30:31 -04:00
David Wheatley
5dd48e1b86
[A11Y] Accessibility improvements for the Search component (#3017)
* Remove deprecated code

* Accessibility improvements for Search component
2021-09-20 16:06:15 +01:00
Rafael Horvat
1b193196da
Use author filter parameter instead of q with gambit to get a user's discussions on the DiscussionsUserPage (#3068) 2021-09-11 09:24:15 +01:00