* 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>
* chore: migrate to Yarn package manager
* chore: bump deps, move `expose-loader` to correct deps section
* fix: remove package from old typescript shim
* feat: use Yarn Plug'n'Play
* chore: keep `node_modules` ignored for people who choose to use npm anyway
* Revert "feat: use Yarn Plug'n'Play"
This reverts commit 9781c8c8d5.
* 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`
* 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>
* 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>
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
* 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
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>
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.
* Add extra error handling for avatar file size & large payload
* Change error message to return 'upload failure' on most errors instead of 'no file' message
Extension admin pages are currently not working because of a JS error.
The settings record is never defined but directly used, it used to be defined as an empty object in oninit.
* Rewrite AdminPage.js into Typescript
* Export more interfaces and types
* Use Stream type
* Update js/src/admin/components/AdminPage.tsx
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Move `HTMLInputTypes` type to global declarations
* Add missing app import
* Export options interface
* Remove unused method
* Add random element ID generator
* Add attrs for Page component
Full rewrite needed later
* Provide correct attrs
* Add missing a11y attributes for help text and labels
* Update TSDoc comment
* Allow Children to be passed for label/help text
* Extract setting types to arrays
* Make Page class abstract; fix incorrect Component generic call
* Mark AdminPage as abstract
* Mark `content` as abstract
* Revert "Move `HTMLInputTypes` type to global declarations"
This reverts commit c900cb3f6d.
* Restore TSDoc on HTMLInputTypes type
* Fix typo
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Rename Button file
* Convert to TS
* Add debug warning helper
Fires `console.warn`, but only when the forum is in debug mode. Can help to inform extension developers of possible issues with their JS code.
* Simplify button content template
* Rewrite Button component
- Prefer `aria-label` over `title`
- Don't duplicate button content to `title` attribute
- Warn in debug mode if button has no accessible content
- Use modern JS/TS syntax (`||=`, spread, etc)
* Update to work with new Button component
* Update warning
Co-authored-by: Matt Kilgore <tankerkiller125@gmail.com>
* Fire warning in `oncreate`
* Format
* Make Button have extensible Attributes type via generics
* Update args type
* Update js/src/common/components/Button.tsx
Co-authored-by: Matt Kilgore <tankerkiller125@gmail.com>
Co-authored-by: David Sevilla Martin <me@datitisev.me>
Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
* Add extra feature to a11y focusring mixin
* Add visually hidden CSS class and mixin
* Visually hide checkboxes (keep in focus/a11y tree)
* Place checkbox focus ring around display element
* Improve mobile checkbox/switch accessibility
* Start of conversion to CSS variables
* Use variable for Badge colors
* Use variable for avatar bg
* Use variable for user card bg
* Use css variables for hero
* Use css variables for buttons
* Use css variables for sidenav links
* Cleaner style attr
Co-authored-by: David Wheatley <hi@davwheat.dev>
* Add `Post-footer--empty` class if the post footer contains no items
* Hide post footer when it has class `Post-footer--empty`
* Swap to `:empty` pseudoselector
* Prefer ternary operator
* Fix typo
In dd8323ee36, insertText was modified from the original to work with reply mentioning. This was done due to a misunderstanding of the API: the selection range isn't the selection to replace, but rather the final selection state after replacing the *current* selection with the text. This commit restores the original, correct implementation of insertText and instead adjusts the `insertBetween`method of BasicEditorDriver to set selection state before executing `insertText`.
Fixes https://github.com/flarum/core/issues/2877
The textarea in the CustomFooterModal was much larger than in the other appearance page modals, and did not use a monospaced font. Turns out the other 2 were explicitly specified in the less. This commit adds a class that can be applied to all these modals for simpler maintenance.
Fixes https://github.com/flarum/core/issues/2865
In b2d053f686, I tried to be clever and create a new KeyboardNavigatable object as a return value for `when`. My approach to cloning was incorrect, and caused the util to break entirely.
My original intent for having this "clone"-based behavior is that a single KeyboardNavigatable instance could be created with multiple listeners, and then "cloned" like this with different "activators" registered via "then" calls. In hindsight, this change introduces more issues than it solves: outside of just not working, the cloned "KeyboardNavigatable" instances have shared internal state (the set of callbacks), and each has write access to this internal state. This is a recipe for unpredictable behavior and confusing bugs, so best to keep things simple for now, and maybe introduce more functional behavior in later releases.
Fixes https://github.com/flarum/QualityAssurance/issues/25
This fixes an error where an empty notification list wouldn't show the "empty" text.
It also simplifies flow of logic and breaks the component up a bit for readability.
* Update core to use new Webpack and TSConfig
* Bump webpack dep
* Update JS build action
* Copy custom `.d.ts` files to `dist-typings` folder on typings compile
* Run workflow against action v2
This allows us to have a moving tag, like first party actions have.
* Remove bundle analyzer from core
* Use webpack config 0.1.0-beta.16.2
* Add note about checking flarum-tsconfig