1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 20:04:24 +02:00

Compare commits

..

240 Commits

Author SHA1 Message Date
Alexander Skvortsov
dd5c516156 Release v1.2.1 2022-03-10 15:47:26 -05:00
Alexander Skvortsov
085c44ec63 chore: rebuild dist js 2022-03-10 15:44:30 -05:00
Alexander Skvortsov
60600f4d2b chore: bump rich text ICU Message formatter
This fixes https://discuss.flarum.org/d/29914-utf-encoding-error-in-title/6
2022-03-10 15:37:44 -05:00
Daniël Klabbers
7a22527b72 update changelog 2022-01-20 13:56:05 +01:00
Daniël Klabbers
bd4d53323c fixing error in tests for missing timezone 2022-01-20 13:42:26 +01:00
Daniel Klabbers
ad69cf84fe Release v1.2 2022-01-20 12:55:30 +01:00
flarum-bot
aa77df46ee Bundled output for commit 19e48617f0
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-20 09:33:26 +00:00
Alexander Skvortsov
19e48617f0 chore: bump rich icu message formatter 2022-01-20 04:27:39 -05:00
Alexander Skvortsov
d8b83cc372 fix: build typings script 2022-01-20 04:24:32 -05:00
Alexander Skvortsov
a04b420295 fix: typings generation script 2022-01-20 04:12:32 -05:00
flarum-bot
5f4b5c0841 Bundled output for commit beae75dab3
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-20 08:25:20 +00:00
Alexander Skvortsov
beae75dab3 chore: fl-dev audit infra --fix 2022-01-20 03:19:22 -05:00
flarum-bot
e304cf7cb5 Bundled output for commit 9f87674626
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-18 18:38:18 +00:00
Alexander Skvortsov
9f87674626 chore: bump @askvortsov/rich-icu-message-formatter (#3264)
Fixes https://github.com/flarum/core/issues/3259
2022-01-18 13:32:30 -05:00
flarum-bot
54329d0827 Bundled output for commit a7aad46068
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-14 05:30:33 +00:00
David Wheatley
a7aad46068 fix: mark near as optional in discussion route (#3257) 2022-01-14 00:25:29 -05:00
flarum-bot
7551a14ae5 Bundled output for commit f4c29db182
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-09 04:01:27 +00:00
Alexander Skvortsov
f4c29db182 fix: Allow outside click on modal focus trap
Without this, alerts triggered while a modal is open can't be dismissed.
2022-01-08 22:55:48 -05:00
Alexander Skvortsov
a291134da1 fix: don't spellcheck custom LESS
This should stop browsers from "correcting" code, and from converting regular quotes to "smart" quotes.
2022-01-08 22:55:48 -05:00
flarum-bot
c702f5e228 Bundled output for commit 749e7e34f7
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-09 00:24:36 +00:00
Alexander Skvortsov
749e7e34f7 Fix frontend branch name 2022-01-08 19:18:02 -05:00
Alexander Skvortsov
67821d95bd fix: Ensure user not false in post component
If no information about a relation exists, it will return false, not undefined. Therefore, the nullsafe operator is not enough to avoid issues here.
2022-01-08 18:26:51 -05:00
StyleCI Bot
aa44677df3 Apply fixes from StyleCI
[ci skip] [skip ci]
2022-01-06 02:47:52 +00:00
Alexander Skvortsov
3978efa533 LogDriver should work in debug mode 2022-01-05 21:47:33 -05:00
Alexander Skvortsov
687e1e2789 Use proper log level depending on debug mode 2022-01-05 21:45:27 -05:00
Alexander Skvortsov
7cec4d1f42 Format 2022-01-04 21:13:42 -05:00
Alexander Skvortsov
fbe1a48bec Fix echo statements not showing up in debug modals or console trace
This was accidentially introduced in the recent Application permissions refactor, where `formattedError`was changed to always be a string array.
2022-01-04 21:13:15 -05:00
David Wheatley
17a8d2c9d8 docs: add missing 1.1.1 changelog
This was present on the 1.1.1 branch, but not `master`.
2022-01-04 15:19:21 +00:00
Alexander Skvortsov
85ee80659d fix: broken post/discussion soft delete (#3249)
* FIx broken post/discussion soft delete

Before the Model typescript rewrite, `pushAttributes` supported including relationship objects, which is hacky but incorrect behavior. With the rewrite, this functionality was broken.

This PR deprecates the functionality, adds a deprecated BC layer with a debug warning, and removes instances of incorrect usage.

* Update js/src/common/Model.ts

Co-authored-by: David Wheatley <hi@davwheat.dev>

* Update js/src/common/Model.ts

Co-authored-by: David Wheatley <hi@davwheat.dev>

* chore: format

Co-authored-by: David Wheatley <hi@davwheat.dev>
2022-01-04 13:26:46 +00:00
Alexander Skvortsov
af77214967 Apply flarum-cli audit fix (#3248) 2022-01-03 16:57:09 -05:00
Alexander Skvortsov
7c3b51fec0 Use v1.0.0 of backend testing properly (#3247) 2022-01-03 16:04:17 -05:00
Sami Mazouz
ed3ea05c1a fix: Until reply renaming permission of discussions broken in php 8 (#3243)
* test: `until reply` rename discussion ability
* fix: `Until reply` renaming of discussions broken in php 8
2021-12-31 20:19:26 +01:00
flarum-bot
9fd6e5d0a2 Bundled output for commit 2541cdec94
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-29 09:43:23 +00:00
David Wheatley
2541cdec94 fix: prevent unwarranted a11y warnings on custom Button subclasses (#3238)
* fix: prevent unwarranted a11y warnings on UploadImageButton

* chore: format

* refactor

* fix: remove attr
2021-12-29 10:37:58 +01:00
David Wheatley
8fac735be0 fix: error in funding composer.json block bricks frontend (#3239)
* fix: error in funding `composer.json` block bricks frontend

* simplify

* Apply fixes from StyleCI

[ci skip] [skip ci]

Co-authored-by: luceos <luceos@users.noreply.github.com>
2021-12-29 03:25:03 +01:00
flarum-bot
53c3d13047 Bundled output for commit 993500aae4
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-28 20:13:43 +00:00
David Wheatley
993500aae4 fix(a11y): fix a11y warning in alert, and other a11y fixes (#3237)
* fix(a11y): fix a11y warning in alert, and other a11y fixes

* chore: correct import

* chore: use `class`
2021-12-28 21:08:34 +01:00
flarum-bot
0e9c169e06 Bundled output for commit 94f9e7f9de
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-28 19:56:55 +00:00
David Wheatley
94f9e7f9de fix: don't fire deprecation warnings for Mithril-originating action (#3236)
* fix: don't fire deprecation warnings for Mithril-originating actions

* Add comment
2021-12-28 20:51:13 +01:00
flarum-bot
4b25b90b48 Bundled output for commit a4fbf16eef
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-28 19:40:54 +00:00
David Wheatley
a4fbf16eef fix: mark render method in RouteResolver as optional (#3235) 2021-12-28 20:36:11 +01:00
David Wheatley
809620750f perf: include request info in first accesstoken touch (#3233) 2021-12-28 10:17:11 +01:00
flarum-bot
066cf02b88 Bundled output for commit cff672424b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-28 01:30:26 +00:00
Alexander Skvortsov
cff672424b Merge pull request #3228 from flarum/as/v1.2_frontend_fixes
Some v1.2 frontend fixes
2021-12-27 20:24:53 -05:00
David Wheatley
2e94e31bb6 perf: only update last time when current value outdated (#3230)
* perf: only update last seen time when current > 120s ago

* perf: only update `last_activity_at` every 2 mins

* docs: add comment

* fix: add missing param

* test: add tests

* tests: attempt tests fix

* fix(tests): call `$this->app()`

* chore: extract hard-coded values out to private consts

* chore: increase diff

* Apply suggestions from code review
2021-12-28 00:39:42 +01:00
Alexander Skvortsov
b7f2fe2429 Fix consecutive shows of same modal with different attrs
We need to specify a unique key for each modal so that the modals are fully destroyed and recreated. For instance, this fixes the signup modal being empty with OAuth register flows.
2021-12-27 18:28:11 -05:00
flarum-bot
64dab138c4 Bundled output for commit 206aa227f2
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 23:18:49 +00:00
Alexander Skvortsov
a55b61e058 Use translations for page titles in frontend
This gives more flexibility for customization, and allows overriding title structure via translations / linguist.
2021-12-27 18:15:12 -05:00
Alexander Skvortsov
206aa227f2 Only retain scroll position if coming from discussion (#3229)
Fixes https://discuss.flarum.org/d/29596-make-tag-hero-visible/8.

If a user has just switched from one tag to another, they want to see the entire new discussion list, and information about which tag that discussion list corresponds to. There's no good reason to not display the hero header when switching tags.
2021-12-27 18:13:29 -05:00
flarum-bot
e926758060 Bundled output for commit ad8ac4e342
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 20:37:36 +00:00
David Wheatley
ad8ac4e342 fix: posts tab on users page broken 2021-12-27 21:32:04 +01:00
flarum-bot
2e5cd6f5c3 Bundled output for commit d5cd0bd339
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 19:59:19 +00:00
David Wheatley
d5cd0bd339 fix: returning null breaking CommentPosts 2021-12-27 20:54:00 +01:00
flarum-bot
09d1e289de Bundled output for commit d65deeccb5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 19:09:19 +00:00
David Wheatley
d65deeccb5 chore: maintenance pre-1.2 release (#3213)
* chore: bump js dependencies

* chore: bump Yarn to 3.1.1

* chore: re-patch TS binary

* chore: don't show diffs for yarn lockfile
2021-12-27 19:04:42 +00:00
flarum-bot
3d62a6af27 Bundled output for commit d268894e61
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-27 19:02:33 +00:00
David Wheatley
d268894e61 chore: 1.2 JS clean-up (#3214)
* fix: `extend.ts` TS error

* docs: fix incorrect JS docblocks

* chore: simplify some code

* chore: remove usages of prefixed JS function

* chore: consistent empty return types

* chore: format

* fix: typing errors

* chore: remove unneeded `@public` docblock modifiers

* Apply suggestions from code review

* Update js/src/forum/utils/slidable.js

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

* Apply suggestions from code review

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-12-27 18:58:18 +00:00
Alexander Skvortsov
d89031f057 Fix drawer focus trap making login form unclickable on mobile
Adding `clickOutsideDeactivates` seems to fix the issue, contrary to what the focus-trap documentation implies about it being unnecessary.
2021-12-26 22:45:58 -05:00
Alexander Skvortsov
0c95d28e94 Fix Search error when user can't search
If there are no search sources, HTML for the Search component won't be rendered, so trying to attach listeners to it will likely error.

In this PR, we don't attach such listeners/logic if there are no sources. We also stop asserting that sources is defined to help avoid other similar issues in the future.
2021-12-26 20:04:48 -05:00
flarum-bot
4df72e5ac6 Bundled output for commit a2f417e9c5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-26 06:29:40 +00:00
David Wheatley
a2f417e9c5 fix: incorrect return type on pushPayload (#3226) 2021-12-26 01:25:16 -05:00
flarum-bot
dc661bf144 Bundled output for commit 7a27f494c6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-22 18:58:42 +00:00
David Wheatley
7a27f494c6 fix: hide WelcomeHero when content is empty (#3219) 2021-12-22 13:54:21 -05:00
Sebastian Kessler
edde6be301 docs: fix broken contribution link in README; add screenshot (#3211) 2021-12-20 14:55:25 -05:00
flarum-bot
96fdaac3ef Bundled output for commit e57655553f
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-20 16:32:17 +00:00
David Wheatley
e57655553f fix: breaking change in Search component - renaming of state property (#3212)
* fix: breaking change in search component's public api

* fix: add setter

* feat: add deprecation warning helper

This reduces bundle size as a result of deprecation warning in our JS, as well as maintaining a consistent format across warnings.

* feat: fire deprecation warning on usage of `Search.state`

* chore: use consistent deprecation warning across core

* fix: `/pull` not `/issue`

* chore: format
2021-12-20 16:28:28 +00:00
David Wheatley
a1cc456f3a fix(postmeta): use app baseUrl instead of location.origin (#3216) 2021-12-20 16:25:04 +00:00
David Wheatley
4ad961c972 feat: allow replacing of blade template namespaces via extender (#3167)
* feat: allow replacing of blade template namespaces

* wip: add `prependNamespace` support

* test: add replace namespace test

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix: add missing property

* test: add prepend test

* fix: add view namespaces before resolving

Allows `replaceNamespace()` extender to actually remove old routes.

* test: make replace test ensure that replaced view does not exist

* docs: update docblock

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix: missing `\` before class

* fix: change test view namespace

* chore: simplify test

* Remove replace namespace code

We only really need prepend.

* chore: rename extender

* ci: add override test

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix(tests): add `trim` call

* revert: 3d46ead14b

Co-authored-by: luceos <luceos@users.noreply.github.com>
2021-12-20 09:56:48 +01:00
flarum-bot
7d9fe8e06b Bundled output for commit a36f98d1fc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-16 08:36:25 +00:00
Sami Mazouz
a36f98d1fc fix: Add a11y labels to auth modal inputs (#3207) 2021-12-16 09:30:34 +01:00
flarum-bot
5befaa6886 Bundled output for commit 726661fe8c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-15 15:53:25 +00:00
David Wheatley
726661fe8c fix: replace throw with debug warning to fix breaking change (#3206)
* fix: replace throw with debug warning to fix breaking change

* Add link back to PR in warning

* fix: add missing `return null` for `!allowUnregistered` code path

* Clean up message -- move more info to PR comment

* Add setTimeout to delay call debug warning call until after `app.forum` is defined

* Add backticks around data type
2021-12-15 10:48:46 -05:00
flarum-bot
b8b9f69820 Bundled output for commit c9a8543554
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-14 22:16:16 +00:00
Ian Morland
c9a8543554 feat: extract notification primaryControl items to an ItemList (#3204) 2021-12-14 22:11:48 +00:00
Ian Morland
6136ce8d8c feat: Add events for Notification read / read all (#3203) 2021-12-14 15:38:50 -05:00
David Wheatley
11fd012f70 feat: add Less custom function extender, is-extension-enabled function (#3190)
Co-authored-by: luceos <luceos@users.noreply.github.com>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2021-12-14 19:25:39 +00:00
Ian Morland
25dc26bac6 Only update notifications that are not already marked as read (#3202) 2021-12-14 19:24:30 +01:00
flarum-bot
10c6694087 Bundled output for commit c88a3e7e89
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-14 17:10:20 +00:00
Alexander Skvortsov
c88a3e7e89 Merge pull request #2961 from the-turk/style-st
Improve selected text stylization
2021-12-14 12:06:22 -05:00
flarum-bot
f7e4413d96 Bundled output for commit e54c5b0924
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-14 03:11:57 +00:00
Alexander Skvortsov
e54c5b0924 Merge pull request #3196 from flarum/as/finish-typing
Finish typing, enable error on TypeScript check failure
2021-12-13 22:07:39 -05:00
Alexander Skvortsov
cbbb574e37 Format and Type Import Cleanup
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-13 22:04:36 -05:00
Alexander Skvortsov
4444357563 Error in GH actions on type failures 2021-12-13 20:20:35 -05:00
Alexander Skvortsov
55dd8f17f3 Fix typing errors with app.modal.show
Unfortunately TypeScript doesn't support higher-kinded types, so we can't write this in a type-safe way.
2021-12-13 20:20:35 -05:00
Alexander Skvortsov
718e01165a Slightly improve AlertManagerState show typing
`typeof Alert` is more correct than `Alert`, since we're accepting classes not instances.
2021-12-13 20:20:35 -05:00
Alexander Skvortsov
311e858c2b VnodeElementTag must be either a string or a class.
Unfortunately, TypeScript only supports strings and classes for JSX tags.
Therefore, our type definition should only allow for those two types.
see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
2021-12-13 20:20:34 -05:00
Alexander Skvortsov
b13bc70339 Format VnodeElementTag fix 2021-12-13 20:20:34 -05:00
Alexander Skvortsov
a90140928c Modal typescript cleanup and conversions 2021-12-13 20:20:34 -05:00
Alexander Skvortsov
162c60e763 alertAttrs can be null 2021-12-13 20:20:34 -05:00
Alexander Skvortsov
174345cf22 Fix LoadingModal attr typings 2021-12-13 20:20:34 -05:00
Alexander Skvortsov
fe9cec0787 Allow any Mithril Children where appropriate 2021-12-13 20:20:33 -05:00
Alexander Skvortsov
1bdfe0112c extractText from translations where strings expected 2021-12-13 20:20:33 -05:00
Alexander Skvortsov
cc69211977 Fix import of mithril for VnodeElementTag usage 2021-12-13 20:20:33 -05:00
Alexander Skvortsov
02a57bfa8e Don't assume app.session.user is present 2021-12-13 20:20:33 -05:00
flarum-bot
0d45f2a881 Bundled output for commit 6c46fc4228
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-14 00:01:04 +00:00
Alexander Skvortsov
6c46fc4228 Merge pull request #3197 from flarum/as/permission-grid-fixes
Permission grid fixes
2021-12-13 18:56:11 -05:00
Alexander Skvortsov
1567ab0cb8 Return undefined => return null 2021-12-13 18:55:25 -05:00
flarum-bot
2554b9e774 Bundled output for commit b77f13b7c6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-13 21:35:24 +00:00
Alexander Skvortsov
b77f13b7c6 Merge pull request #3200 from flarum/as/1_2_assorted_frontend_patches
A few frontend fixes for v1.2
2021-12-13 16:31:18 -05:00
Alexander Skvortsov
080442d085 Sync with v2.1 of markdown-toolbar-element 2021-12-13 16:03:34 -05:00
Hasan Özbey
fb82afa97f improve selected text stylization 2021-12-13 15:14:23 -05:00
Alexander Skvortsov
508be96f15 Don't throw errors for undefined relationships 2021-12-13 15:07:30 -05:00
Alexander Skvortsov
364575b3f0 Make sure this.data.attributes is initialized.
`Object.assign` is not type-safe, and does ensure that the property being assigned to is not undefined.
2021-12-13 12:34:51 -05:00
Sami Mazouz
c7791b63f7 perf: Allow loading relations in other discussion endpoints (#3191) 2021-12-13 11:34:26 +01:00
flarum-bot
dc48e2327b Bundled output for commit 6b7dfaa598
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-13 07:03:23 +00:00
Alexander Skvortsov
4ade45e67a Don't lazy draw permissions dropdown
It is already lazy drawn, see 23a70affa6/js/src/admin/components/PermissionDropdown.js (L63-L63)
2021-12-13 02:00:06 -05:00
Alexander Skvortsov
46893a9749 PermissionGrid fixes
Fixes https://github.com/flarum/core/issues/3169#issuecomment-979470794

- Restore wrapping `scope.render` results in a table cell tag. This was accidentially introduced in 924815b6e1, and caused the issue linked above
- Rename the `SettingDropdown` attr `key` to `setting` in order to avoid naming clashes with Mithril vnode keys. `key` still works, but is deprecated.
2021-12-13 02:00:06 -05:00
Alexander Skvortsov
6b7dfaa598 Format 2021-12-13 01:58:47 -05:00
Alexander Skvortsov
d0c160923d Fix listItems to unbrick admin extension pages
https://github.com/flarum/core/pull/3176 accidentially stopped adding a `key` attribute to wrappers of non-vnode inputs. This resulted in "all or no vnodes must have keys" errors.
2021-12-13 01:34:05 -05:00
flarum-bot
c2ec848744 Bundled output for commit 187b5c6f0b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-13 01:41:29 +00:00
Alexander Skvortsov
187b5c6f0b Merge pull request #3174 from flarum/as/models-typing
Typescript for models
2021-12-12 20:37:32 -05:00
Ian Morland
bd8ebb00a0 feat: Allow switching the ImageManager driver (#3195) 2021-12-12 22:34:10 +01:00
Alexander Skvortsov
f26ad3e32d Minor typefixes, fomat 2021-12-12 15:46:46 -05:00
Alexander Skvortsov
4759395186 Post's discussion should always be present 2021-12-12 15:39:45 -05:00
Alexander Skvortsov
a2c8407dd4 params arguments for id-based app.store.find should be optional 2021-12-12 15:39:28 -05:00
Alexander Skvortsov
306b3a9e8b Type-safe session instantiation 2021-12-12 15:39:06 -05:00
Alexander Skvortsov
4444e7c788 Rename Discussion, User files to allow jsx 2021-12-12 15:18:37 -05:00
Alexander Skvortsov
4bd5bc87ee Update js/src/common/models/User.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:37 -05:00
Alexander Skvortsov
528c964d94 Update js/src/common/models/User.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:36 -05:00
Alexander Skvortsov
3bca30121b Update js/src/common/models/Discussion.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:36 -05:00
Alexander Skvortsov
53180a38ac Update js/src/common/Store.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:36 -05:00
Alexander Skvortsov
d82073c3a9 Update js/src/common/Model.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:36 -05:00
Alexander Skvortsov
44efff342d Update js/src/common/Model.ts
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 15:18:36 -05:00
Alexander Skvortsov
0bdb018ad4 Add meta to ApiPayload interfaces 2021-12-12 15:18:35 -05:00
Alexander Skvortsov
b0504597da Review changes, make Model.store non-nullable, include meta in APIPayload signatures 2021-12-12 15:18:35 -05:00
Alexander Skvortsov
b85aa403cc Remove unnecessary nonnull assertions 2021-12-12 15:18:35 -05:00
Alexander Skvortsov
ab2620147a Drop unnecessary JSDocs 2021-12-12 15:18:35 -05:00
Alexander Skvortsov
09a55258a0 format 2021-12-12 15:18:34 -05:00
Alexander Skvortsov
3a8d640dab Clean up model nullability 2021-12-12 15:18:34 -05:00
Alexander Skvortsov
bbc9143404 Convert models to TS 2021-12-12 15:18:34 -05:00
flarum-bot
7be0c02ba1 Bundled output for commit 580be37eb4
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-12 19:55:47 +00:00
Alexander Skvortsov
580be37eb4 listItems typing fix (#3176)
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-12 14:51:05 -05:00
Ian Morland
0e00196d8e Make SlugManager available to blade template (#3194)
* Make SlugManager available to blade template

* Use
2021-12-12 20:40:38 +01:00
flarum-bot
a57ef5a3d5 Bundled output for commit 325b9afca6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-12 19:35:29 +00:00
Ian Morland
325b9afca6 fix: getPlainContent causes external content to be fetched (#3193) 2021-12-12 14:30:56 -05:00
flarum-bot
1a420828aa Bundled output for commit 57b413ada5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-11 17:37:26 +00:00
Alexander Skvortsov
57b413ada5 Split up application error handling (#3184)
Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-12-11 12:32:51 -05:00
flarum-bot
326b787130 Bundled output for commit 0f2824e0f4
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-07 18:55:28 +00:00
Rafał Całka
0f2824e0f4 Make StatusWidget tools extensible (#3189) 2021-12-07 13:50:40 -05:00
Daniël Klabbers
7bab6eddf6 Use revision versioner to allow custom asset versioning (#3183) 2021-12-06 12:49:21 -05:00
flarum-bot
b7a9911ffb Bundled output for commit c219699024
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-06 17:07:57 +00:00
David Wheatley
c219699024 fix: clicking three dots on post opens all dropdowns in .Post-actions (#3185) 2021-12-06 18:03:07 +01:00
Alexander Skvortsov
dcc9868129 Centralize pagination/canonical meta URL generation in Document (#3077)
* Centralize pagination/canonical meta URL generation in Document

* Apply fixes from StyleCI

[ci skip] [skip ci]

* Use translations for title template

* Apply fixes from StyleCI

[ci skip] [skip ci]

* Dont add translator to title driver interface

It's an implementation detail, and can be made available on specific implementations as needed.

Co-authored-by: Alexander Skvortsov <askvortsov1@users.noreply.github.com>
2021-12-03 13:31:50 -05:00
flarum-bot
02f351001c Bundled output for commit 6a909386b2
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-02 16:21:19 +00:00
Ian Morland
6a909386b2 Move colorItems to ItemList (#3186) 2021-12-02 11:16:50 -05:00
flarum-bot
17d25ba4ce Bundled output for commit c7662a320f
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-01 22:10:25 +00:00
Alexander Skvortsov
c7662a320f Fix app.route initialization
The first argument being an object breaks the forum, since a function can work in `Object.assign` if it is the first argument.
2021-12-01 17:05:57 -05:00
flarum-bot
5a9f60d250 Bundled output for commit c522657212
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-01 20:21:28 +00:00
Alexander Skvortsov
c522657212 Improve avatar upload experience (#3181)
Fixes https://github.com/flarum/core/issues/3055

- On the frontend, accept only image types as a hint to the OS file picker.
- On the backend, add more robust validation to ensure only valid images make it through. This isn't necessary for security, but results in less confusing error mesages.
2021-12-01 15:16:45 -05:00
flarum-bot
2b87f10738 Bundled output for commit 29c290e78f
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-12-01 16:32:02 +00:00
Alexander Skvortsov
29c290e78f Convert routes to Typescript (#3177) 2021-12-01 11:27:19 -05:00
flarum-bot
38c3ccd6be Bundled output for commit 71cb8c378f
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-26 22:30:49 +00:00
Alexander Skvortsov
71cb8c378f Add typing files for our translator libraries (#3175) 2021-11-26 17:26:37 -05:00
flarum-bot
94370375a5 Bundled output for commit afbf5f4905
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-23 22:58:48 +00:00
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
flarum-bot
1832fb090d Bundled output for commit 94c4f266e3
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-23 21:43:22 +00: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
flarum-bot
c96fa49853 Bundled output for commit a203469109
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-23 13:06:36 +00:00
Sami Mazouz
a203469109 fix: Modal typings complicate inheritance (#3178) 2021-11-23 14:02:14 +01:00
David Wheatley
86d23a5de2 chore: use @php in Blade templates (#3172)
* chore: remove comment

* chore: use `@php` in blade templates

* chore: use `@php` in blade templates
2021-11-23 12:55:36 +00:00
David Wheatley
bb817d9a90 fix(a11y): show post action items when focus is within the post (#3173)
* fix: show post action items when focus is within the post

* fix: add missing `&`
2021-11-21 20:25:00 +00:00
flarum-bot
9117747d41 Bundled output for commit eaf1b86785
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-21 19:49:09 +00: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
flarum-bot
b2c83debb3 Bundled output for commit d82ae27231
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-19 17:46:08 +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
7242b18ff0 Fix test cases for SetSettingsController 2021-11-16 16:54:23 -05:00
Alexander Skvortsov
f53a81bc18 Apply fixes from StyleCI
[ci skip] [skip ci]
2021-11-16 21:50:53 +00:00
Alexander Skvortsov
7c12e2c464 Add integration tests for settings API endpoint 2021-11-16 16:48:09 -05:00
flarum-bot
34e0ab6100 Bundled output for commit 390caa51db
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-16 20:55:56 +00: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
Daniël Klabbers
09fdd4cb6d fix: allow queue restarting (#3166)
By injecting the cache store into the queue, we allow queues to be
restarted using php flarum queue:restart and similar events dispatched
from within Laravelish classes.
2021-11-16 10:46:31 -05:00
flarum-bot
b4a44f70d9 Bundled output for commit c120f28d42
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-16 14:09:23 +00:00
Ian Morland
c120f28d42 Add priority order to discussion controls (#3165) 2021-11-16 15:04:54 +01:00
Garrett Grimm
5993c647a5 fix: enforce 65k character limit for setting values (#3162)
* Enforce 65k limit when attempting to store setting values.

* Add space for style.

* Move setting validation into Saving event listener.

* Use consistent var names

* remove extra space

* Move settings validation into separate class.

* Remove unused class.

* Remove extra line.

* Move ValidateCustomLess to SettingsServiceProvider.  Use existing convention for validator.

* Update src/Settings/SettingsValidator.php

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

* Revert moving of ValidateCustomLess logic.  Allow for attribute specific setting validation rules.

* Style fixes.

* Style fixes.

* Style fixes.

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-11-12 18:43:57 +00:00
flarum-bot
359e9f6cbb Bundled output for commit d72b8b8d8e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-12 00:58:35 +00:00
Alexander Skvortsov
d72b8b8d8e Fix some typing errors 2021-11-11 19:53:44 -05:00
flarum-bot
312ff057f8 Bundled output for commit 9b9ca53b81
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-11 20:59:55 +00: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
Garrett Grimm
4ffc26a13a Adjust boolean check of is_email_confirmed to suppress extraneous user activation events (#3163) 2021-11-11 15:51:47 -05:00
flarum-bot
5f110f73e7 Bundled output for commit cab2e797eb
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-11 20:05:26 +00: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
flarum-bot
ec5214f714 Bundled output for commit bac0e594ee
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-11 19:21:56 +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
563d40d7da chore: migrate fully to Yarn (#3155)
* 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.
2021-11-10 20:10:25 +00:00
Daniel Klabbers
bfd81a83cf fix(logs): assign INFO scope to correct argument
Argument for INFO (constant value 200) was assigned to
maxfiles argument incorrectly.
2021-11-09 14:48:53 +01:00
flarum-bot
833c7540a3 Bundled output for commit ad2cef70d2
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-09 03:35:53 +00:00
David Wheatley
ad2cef70d2 chore: better typings for DiscussionListState (#3132) 2021-11-08 22:33:52 -05:00
flarum-bot
541684ee2a Bundled output for commit ec730d2615
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-08 23:55:13 +00: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
Sami Mazouz
f9f398b532 feat: Use an extensible document title driver implementation (#3109)
* feat: Use an extensible document title driver implementation
* chore: Add todo to use DI in 2.0
2021-11-08 23:15:32 +01:00
flarum-bot
4c61687833 Bundled output for commit b90001d98c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-08 21:54:19 +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
flarum-bot
6aad961545 Bundled output for commit e797276606
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-08 21:35:22 +00:00
Alexander Skvortsov
e797276606 Use calculated offset when loading page in PaginatedListState (#3159) 2021-11-08 16:33:07 -05:00
flarum-bot
8e52ec373e Bundled output for commit 0957cca9e2
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-08 18:42:22 +00: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
flarum-bot
2daee924c5 Bundled output for commit 8c47b197f0
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-04 21:40:48 +00:00
David Wheatley
8c47b197f0 fix: Component.component argument typings (#3148) 2021-11-04 21:38:50 +00:00
Sami Mazouz
809df29d29 feat: Declare & Use CSS Custom Properties (#3146) 2021-11-04 22:34:18 +01:00
flarum-bot
26bf5d350b Bundled output for commit 6eb05cfbad
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-03 23:23:42 +00:00
David Wheatley
6eb05cfbad chore: replace for ... in with Array.reduce (#3149) 2021-11-03 23:21:47 +00:00
Clark Winkelmann
8a69c890e7 Fix post policy for PHP 8 (#3145)
* Add tests to verify post policy works as intended
* Fix "reply" post edit setting not working on PHP 8

Fixes #3144
2021-11-01 16:38:21 -04:00
flarum-bot
9e1b05a358 Bundled output for commit 497dccee56
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-11-01 15:18:09 +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
Sami Mazouz
d8e7aa54b4 feat: Allow registering settings as Less config vars through Settings Extender (#3011)
Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-11-01 15:41:19 +01:00
Sami Mazouz
2b163025d6 feat: Create loadWhere relations extender (#3116) 2021-11-01 10:45:02 +01:00
flarum-bot
7b80d3932d Bundled output for commit c44cf42e2c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-31 20:20:31 +00:00
Dan Wallis
c44cf42e2c Deprecate unused evented utility (#3125) 2021-10-31 16:18:44 -04:00
Sami Mazouz
fcf23ee8d5 feat: Default Settings Extender (#3127)
Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-10-31 21:09:06 +01:00
flarum-bot
7b2adf3b96 Bundled output for commit cb6405110c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-31 18:23:34 +00:00
Alexander Skvortsov
cb6405110c Support, update to webpack 5 (#3135) 2021-10-31 14:21:17 -04:00
flarum-bot
89dfad5f38 Bundled output for commit 1e595e752a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-30 23:18:37 +00:00
David Sevilla Martin
1e595e752a Add textarea setting type to AdminPage#buildSettingComponent (#3141) 2021-10-30 19:16:21 -04:00
flarum-bot
a6f660236f Bundled output for commit f260bd7efe
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-30 23:15:48 +00:00
David Sevilla Martin
f260bd7efe Switch to constructor MIN_SEARCH_LENGTH in Search component (#3130) 2021-10-30 19:13:43 -04:00
flarum-bot
823c337c1e Bundled output for commit f8232b9c1b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-30 22:46:26 +00: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
flarum-bot
45927f1068 Bundled output for commit 7db2d0f697
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-30 22:31:34 +00: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
flarum-bot
6ba385eea6 Bundled output for commit 70588959eb
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-29 22:39:58 +00:00
David Sevilla Martin
70588959eb fix: remove 'typeof' in 'typeof this' from AdminPage#buildSettingComponent params (#3142) 2021-10-30 00:37:41 +02:00
flarum-bot
8c3d92c427 Bundled output for commit acf16fdf2e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-29 18:33:41 +00:00
Sami Mazouz
acf16fdf2e chore: Minor Readme CSS code tidy up (#3138) 2021-10-29 19:31:15 +01:00
David Wheatley
a1b5ef5154 fix: issue with CSS styles when in-between whole pixel values for viewport width (#3139)
* fix: issue with CSS styles when in-between whole pixel values for viewport width

Fixes #2915

* chore: add explanatory comment

* fix: add missing slash
2021-10-29 18:57:53 +01:00
flarum-bot
02c2df681d Bundled output for commit 2000727e94
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-29 17:35:09 +00: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
flarum-bot
33841d1e25 Bundled output for commit 28ead83b04
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-28 01:59:00 +00: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
flarum-bot
247ace2f04 Bundled output for commit e0b6190733
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-27 21:01:48 +00: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
flarum-bot
f66a7ef7cc Bundled output for commit e550b15cea
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-27 20:44:05 +00: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
flarum-bot
db6c8b8774 Bundled output for commit 4982efed3a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-10-27 20:17:11 +00:00
David Wheatley
4982efed3a chore: bump JS dependencies (#3134) 2021-10-27 16:14:26 -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
454 changed files with 15077 additions and 18198 deletions

1
.gitattributes vendored
View File

@@ -13,5 +13,6 @@ tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
js/dist-typings/* linguist-generated
js/yarn.lock -diff
* text=auto eol=lf

15
.github/workflows/backend.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: Core PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
with:
enable_backend_testing: true
backend_directory: .

21
.github/workflows/frontend.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Core JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
with:
enable_bundlewatch: true
enable_prettier: true
enable_typescript: true
frontend_directory: ./js
main_git_branch: master
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -1,91 +0,0 @@
name: JS
on: [workflow_dispatch, push, pull_request]
env:
NODE_VERSION: 16
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: js/package-lock.json
- name: Install JS dependencies
run: npm ci
working-directory: ./js
- name: Check JS formatting
run: npm run format-check
working-directory: ./js
build-prod:
name: Build and commit
runs-on: ubuntu-latest
needs: [prettier]
# Only commit JS on push to master branch
# Remember to change in `build-test` job too
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: js/package-lock.json
# Our action will install npm, cd into `./js`, run `npm run build` and
# `npm run build-typings`, then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: npm
typings_script: build-typings
build-test:
name: Test build
runs-on: ubuntu-latest
needs: [prettier]
# Inverse check of `build-prod`
# Remember to change in `build-prod` job too
if: github.ref != 'refs/heads/master' || github.event_name != 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
cache-dependency-path: js/package-lock.json
# Our action will install npm, cd into `./js`, run `npm run build` and
# `npm run build-typings`, then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: npm
typings_script: build-typings
do_not_commit: true

View File

@@ -1,45 +0,0 @@
name: Bundle size checker
on:
workflow_dispatch:
push:
paths:
- "js/**"
pull_request:
paths:
- "js/**"
jobs:
bundlewatch:
runs-on: ubuntu-latest
name: Bundlewatch
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Use npm v7
run: sudo npm install -g npm@7.x.x
- name: Install JS dependencies
# We need to use `npm install` here. If we don't, the workflow will fail.
run: npm install
working-directory: ./js
- name: Build production assets
run: npm run build
working-directory: ./js
- name: Check bundle size change
run: node_modules/.bin/bundlewatch --config .bundlewatch.config.json
working-directory: ./js
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

View File

@@ -1,79 +0,0 @@
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.3, 7.4, '8.0', '8.1']
service: ['mysql:5.7', mariadb]
prefix: ['', flarum_]
include:
- service: 'mysql:5.7'
db: MySQL
- service: mariadb
db: MariaDB
- prefix: flarum_
prefixStr: (prefix)
exclude:
- php: 7.3
service: 'mysql:5.7'
prefix: flarum_
- php: 7.3
service: mariadb
prefix: flarum_
- php: 8.0
service: 'mysql:5.7'
prefix: flarum_
- php: 8.0
service: mariadb
prefix: flarum_
services:
mysql:
image: ${{ matrix.service }}
ports:
- 13306:3306
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@0b9d33cd0782337377999751fc10ea079fdd7104 # pin@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
tools: phpunit, composer:v2
# The authentication alter is necessary because newer mysql versions use the `caching_sha2_password` driver,
# which isn't supported prior to PHP7.4
# When we drop support for PHP7.3, we should remove this from the setup.
- name: Create MySQL Database
run: |
sudo systemctl start mysql
mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" --port 13306
- name: Install Composer dependencies
run: composer install
- name: Setup Composer tests
run: composer test:setup
env:
DB_PORT: 13306
DB_PASSWORD: root
DB_PREFIX: ${{ matrix.prefix }}
- name: Run Composer tests
run: composer test
env:
COMPOSER_PROCESS_TIMEOUT: 600

3
.gitignore vendored
View File

@@ -1,7 +1,7 @@
/vendor
composer.lock
composer.phar
node_modules
.DS_Store
Thumbs.db
tests/.phpunit.result.cache
@@ -9,3 +9,4 @@ tests/.phpunit.result.cache
.vagrant
.idea/*
.vscode
js/coverage-ts

View File

@@ -1,5 +1,120 @@
# Changelog
## [1.2.1](https://github.com/flarum/core/compare/v1.2.0...v1.2.1)
### Fixed
- Don't escape single quotes in discussion title meta tags (60600f4d2b8f0c5dac94c329041427a0a08fad42)
## [1.2.0](https://github.com/flarum/core/compare/v1.1.1...v1.2.0)
### Added
- View `README` documentation in extension pages (https://github.com/flarum/core/pull/3094).
- Declare & Use CSS Custom Properties (https://github.com/flarum/core/pull/3146).
- Lazy draw dropdowns to improve performance (https://github.com/flarum/core/pull/2925).
- Default Settings Extender (https://github.com/flarum/core/pull/3127).
- Add `textarea` setting type to admin pages (https://github.com/flarum/core/pull/3141).
- Allow registering settings as `Less` config vars through Settings Extender (https://github.com/flarum/core/pull/3011).
- Allow replacing of blade template namespaces via extender (https://github.com/flarum/core/pull/3167).
- Update to Webpack 5 (https://github.com/flarum/core/pull/3135).
- Introduce `Less` custom function extender with a `is-extension-enabled` function (https://github.com/flarum/core/pull/3190).
- Support for `few` in ICU Message syntax (https://github.com/flarum/core/pull/3122).
- ES6 local support for number formatting (https://github.com/flarum/core/pull/3099).
- Added dedicated endpoint for retrieving single groups (https://github.com/flarum/core/pull/3084).
- Callback `loadWhere` relation eager loading extender (https://github.com/flarum/core/pull/3116).
- Extensible document title driver implementation (https://github.com/flarum/core/pull/3109).
- Type checks, typescript coverage GH action (https://github.com/flarum/core/pull/3136).
- Add color indicator in appearance admin page instead of validating colors (https://github.com/flarum/core/pull/3140).
- Add typing files for our translator libraries (https://github.com/flarum/core/pull/3175).
- `StatusWidget` tools extensibility (https://github.com/flarum/core/pull/3189).
- Allow switching the `ImageManager` driver (https://github.com/flarum/core/pull/3195).
- Events for notification read/all read actions (https://github.com/flarum/core/pull/3203).
### Changed
- Testing with php8.1 (https://github.com/flarum/core/pull/3102).
- Migrate fully to Yarn (https://github.com/flarum/core/pull/3155).
- Handle post rendering errors to avoid crashes (https://github.com/flarum/core/pull/3061).
- Added basic filtering, sorting, and pagination to groups endpoint (https://github.com/flarum/core/pull/3084).
- Pass IP address to API Client pipeline (https://github.com/flarum/core/pull/3124).
- Rename Extension Page "Uninstall" to "Purge" (https://github.com/flarum/core/pull/3123).
- [A11Y] Improve accessibility for discussion reply count on post stream (https://github.com/flarum/core/pull/3090).
- Improved post loading support (https://github.com/flarum/core/pull/3100).
- Rewrite SubtreeRetainer into Typescript (https://github.com/flarum/core/pull/3137).
- Rewrite ModalManager and state to Typescript (https://github.com/flarum/core/pull/3007).
- Rewrite frontend application files to Typescript (https://github.com/flarum/core/pull/3006).
- Allow extensions to modify the minimum search length in the Search component (https://github.com/flarum/core/pull/3130).
- Allow use of any tag in `listItems` helper (https://github.com/flarum/core/pull/3147).
- Replace `for ... in` with `Array.reduce` (https://github.com/flarum/core/pull/3149).
- Page title format is now implemented through translations (https://github.com/flarum/core/pull/3077, https://github.com/flarum/core/pull/3228)
- Add `aria-label` attribute to the navigation drawer button (https://github.com/flarum/core/pull/3157).
- Convert extend util to TypeScript (https://github.com/flarum/core/pull/2928).
- Better typings for DiscussionListState (https://github.com/flarum/core/pull/3132).
- Rewrite ItemList, update `ItemList` typings (https://github.com/flarum/core/pull/3005).
- Add priority order to discussion page controls (https://github.com/flarum/core/pull/3165).
- Use `@php` in Blade templates (https://github.com/flarum/core/pull/3172).
- Convert some common classes/utils to TS (https://github.com/flarum/core/pull/2929).
- Convert routes to Typescript (https://github.com/flarum/core/pull/3177).
- Move admin `colorItems` to an `ItemList` (https://github.com/flarum/core/pull/3186).
- Centralize pagination/canonical meta URL generation in Document (https://github.com/flarum/core/pull/3077).
- Use revision versioner to allow custom asset versioning (https://github.com/flarum/core/pull/3183).
- Split up application error handling (https://github.com/flarum/core/pull/3184).
- Make SlugManager available to blade template (https://github.com/flarum/core/pull/3194).
- Convert models to TS (https://github.com/flarum/core/pull/3174).
- Allow loading relations in other discussion endpoints (https://github.com/flarum/core/pull/3191).
- Improve selected text stylization (https://github.com/flarum/core/pull/2961).
- Extract notification `primaryControl` items to an ItemList (https://github.com/flarum/core/pull/3204).
- Frontend code housekeeping (#3214, #3213).
- Only retain scroll position if coming from discussion (https://github.com/flarum/core/pull/3229).
- Use `aria-live` regions to focus screenreader attention on alerts as they appear (https://github.com/flarum/core/pull/3237).
- Prevent unwarranted `a11y` warnings on custom Button subclasses (https://github.com/flarum/core/pull/3238).
### Fixed
- Missing locale text in the user editing modal (https://github.com/flarum/core/pull/3093).
- Dashes in table prefix prevent installation (https://github.com/flarum/core/pull/3089).
- Missing autocomplete attributes to input fields (https://github.com/flarum/core/pull/3088).
- Missing route parameters throwing an error (https://github.com/flarum/core/pull/3118).
- Mail settings select component never used (https://github.com/flarum/core/pull/3120).
- White avatar image throws javascript errors on the profile page (https://github.com/flarum/core/pull/3119).
- Unformatted avatar upload validation errors (https://github.com/flarum/core/pull/2946).
- Webkit input clear button shows up with the custom one (https://github.com/flarum/core/pull/3128).
- Media query breakpoints conflict with Windows display scaling (https://github.com/flarum/core/pull/3139).
- `typeof this` not recognized by some IDEs (https://github.com/flarum/core/pull/3142).
- `Model.save()` cannot save `null` `hasOne` relationship (https://github.com/flarum/core/pull/3131).
- Edit post `until reply` policy broken on PHP 8 (https://github.com/flarum/core/pull/3145).
- Inaccurate `Component.component` argument typings (https://github.com/flarum/core/pull/3148).
- Scrolling notification list infinitely repeats (https://github.com/flarum/core/pull/3159).
- Argument for INFO constant was assigned to `maxfiles` argument incorrectly (bfd81a83cfd0fa8125395a147ff0c9ce622f38e3).
- `Activated` event is sent every time an email is confirmed instead of just once (https://github.com/flarum/core/pull/3163).
- [A11Y] Modal close button missing accessible label (https://github.com/flarum/core/pull/3161).
- [A11Y] Auth modal inputs missing accessible labels (https://github.com/flarum/core/pull/3207).
- [A11Y] Triggering click on drawer button can cause layered backdrops (https://github.com/flarum/core/pull/3018).
- [A11Y] Focus can leave open nav drawer on mobile (https://github.com/flarum/core/pull/3018).
- [A11Y] Post action items not showing when focus is within the post (https://github.com/flarum/core/pull/3173).
- [A11Y] Missing accessible label for alert dismiss button (https://github.com/flarum/core/pull/3237).
- Error accessing the forum after saving a setting with more than 65k characters (https://github.com/flarum/core/pull/3162).
- Cannot restart queue from within (https://github.com/flarum/core/pull/3166).
- `Post--by-actor` not showing when comparing user instances (https://github.com/flarum/core/pull/3170).
- Incorrect typings for Modal `hide()` method (https://github.com/flarum/core/pull/3180).
- Avatar Upload throws errors with correct mimetype and incorrect extension (https://github.com/flarum/core/pull/3181).
- Clicking the dropdown button on a post opens all dropdowns in `Post-actions` (https://github.com/flarum/core/pull/3185).
- `getPlainContent()` causes external content to be fetched (https://github.com/flarum/core/pull/3193).
- `listItems` not accepting all `Mithril.Children` (https://github.com/flarum/core/pull/3176).
- Notifications mark as read option updates all notifications including the read ones (https://github.com/flarum/core/pull/3202).
- Post meta permalink not properly generated (https://github.com/flarum/core/pull/3216).
- Broken contribution link in README (https://github.com/flarum/core/pull/3211).
- `WelcomeHero` is displayed when content is empty (https://github.com/flarum/core/pull/3219).
- `last_activity_at, last_seen_at` updated on all API requests (https://github.com/flarum/core/pull/3231).
- `RememberMe` access token updated twice in API requests (https://github.com/flarum/core/pull/3233).
- Error in `funding` item in `composer.json` bricks the frontend (https://github.com/flarum/core/pull/3239).
- Escaped quotes in window title (https://github.com/flarum/core/pull/3264)
- `schedule:list` command fails due to missing timezone configuration.
### Deprecated
- Unused `evented` utility (https://github.com/flarum/core/pull/3125).
## [1.1.1](https://github.com/flarum/core/compare/v1.1.0...v1.1.1)
### Fixed
- Performance issue with very large communities.
## [1.1.0](https://github.com/flarum/core/compare/v1.0.4...v1.1.0)

View File

View File

@@ -9,7 +9,6 @@
<a href="https://github.styleci.io/repos/28257573"><img src="https://github.styleci.io/repos/28257573/shield?style=flat" alt="StyleCI"></a>
</p>
## About Flarum
**[Flarum](https://flarum.org/) is a delightfully simple discussion platform for your website.** It's fast and easy to use, with all the features you need to run a successful community. It is designed to be:
@@ -20,13 +19,15 @@
* **Powerful and extensible.** Customize, extend, and integrate Flarum to suit your community. Flarums architecture is amazingly flexible, with a powerful Extension API.
![Screenshot of a Flarum instance, showing multiple discussions and tags.](https://flarum.org/assets/img/home-screenshot.png)
## Installation
This repository contains Flarum's core code. If you want to set up a forum, visit the [Flarum skeleton repository](https://github.com/flarum/flarum).
This repository contains Flarum's core code. If you want to set up a forum, visit the [Flarum skeleton repository](https://github.com/flarum/flarum). For support, refer to the [documentation](https://docs.flarum.org/), and ask questions on [Flarum Discuss](https://discuss.flarum.org/) (our community forum) or [Discord server](https://flarum.org/discord/).
## Contributing
Thank you for considering contributing to Flarum! Please read the **[Contributing guide](https://flarum.org/docs/contributing.html)** to learn how you can help.
Thank you for considering contributing to Flarum! Please read the **[Contributing guide](https://docs.flarum.org/contributing)** to learn how you can help.
## Security Vulnerabilities

View File

@@ -86,7 +86,7 @@
"wikimedia/less.php": "^3.0"
},
"require-dev": {
"flarum/testing": "1.0@dev"
"flarum/testing": "^1.0.0"
},
"autoload": {
"psr-4": {
@@ -107,6 +107,28 @@
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"flarum-cli": {
"excludeScaffolding": [
"LICENSE.md",
"js/tsconfig.json",
"js/webpack.config.js"
],
"modules": {
"backendTesting": true,
"js": true,
"gitConf": true,
"githubActions": true,
"prettier": true,
"typescript": true,
"bundlewatch": true,
"editorConfig": true,
"styleci": true,
"admin": true,
"forum": true,
"jsCommon": true,
"css": true
}
}
},
"scripts": {

9
js/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
node_modules

768
js/.yarn/releases/yarn-3.1.1.cjs vendored Executable file

File diff suppressed because one or more lines are too long

3
js/.yarnrc.yml Normal file
View File

@@ -0,0 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.1.1.cjs

View File

@@ -1,2 +1,2 @@
export * from './src/common';
export * from './src/forum';
export * from './src/admin';

View File

@@ -1,3 +1,41 @@
declare type Writable<T> = { -readonly [P in keyof T]: T[P] };
declare type DeepWritable<T> = { -readonly [P in keyof T]: DeepWritable<T[P]> };
declare type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> };
/**
* UTILITY TYPES
*/
/**
* Type that returns an array of all keys of a provided object that are of
* of the provided type, or a subtype of the type.
*/
declare type KeysOfType<Type extends object, Match> = {
[Key in keyof Type]-?: Type[Key] extends Match ? Key : never;
};
/**
* Type that matches one of the keys of an object that is of the provided
* type, or a subtype of it.
*/
declare type KeyOfType<Type extends object, Match> = KeysOfType<Type, Match>[keyof Type];
type Component<A> = import('mithril').Component<A>;
declare type ComponentClass<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = {
new (...args: any[]): Component<Attrs>;
prototype: C;
};
/**
* Unfortunately, TypeScript only supports strings and classes for JSX tags.
* Therefore, our type definition should only allow for those two types.
*
* @see https://github.com/microsoft/TypeScript/issues/14789#issuecomment-412247771
*/
declare type VnodeElementTag<Attrs = Record<string, unknown>, C extends Component<Attrs> = Component<Attrs>> = string | ComponentClass<Attrs, C>;
/**
* @deprecated Please import `app` from a namespace instead of using it as a global variable.
*
@@ -21,6 +59,17 @@ declare const app: never;
declare const m: import('mithril').Static;
declare const dayjs: typeof import('dayjs');
/**
* From https://github.com/lokesh/color-thief/issues/188
*/
declare module 'color-thief-browser' {
type Color = [number, number, number];
export default class ColorThief {
getColor: (img: HTMLImageElement | null) => Color;
getPalette: (img: HTMLImageElement | null) => Color[];
}
}
type ESModule = { __esModule: true; [key: string]: unknown };
/**
@@ -80,3 +129,10 @@ interface JSX {
attrs: Record<string, unknown>;
};
}
interface Event {
/**
* Whether this event should trigger a Mithril redraw.
*/
redraw: boolean;
}

View File

@@ -1,3 +1,30 @@
import Application from '../common/Application';
import ExtensionData from './utils/ExtensionData';
export declare type Extension = {
id: string;
version: string;
description?: string;
icon?: {
name: string;
};
links: {
authors?: {
name?: string;
link?: string;
}[];
discuss?: string;
documentation?: string;
support?: string;
website?: string;
donate?: string;
source?: string;
};
extra: {
'flarum-extension': {
title: string;
};
};
};
export default class AdminApplication extends Application {
extensionData: ExtensionData;
extensionCategories: {
@@ -8,10 +35,27 @@ export default class AdminApplication extends Application {
history: {
canGoBack: () => boolean;
getPrevious: () => void;
backUrl: () => any;
backUrl: () => string;
back: () => void;
};
getRequiredPermissions(permission: any): string[];
/**
* Settings are serialized to the admin dashboard as strings.
* Additional encoding/decoding is possible, but must take
* place on the client side.
*
* @inheritdoc
*/
data: Application['data'] & {
extensions: Record<string, Extension>;
settings: Record<string, string>;
modelStatistics: Record<string, {
total: number;
}>;
};
constructor();
/**
* @inheritdoc
*/
mount(): void;
getRequiredPermissions(permission: string): string[];
}
import Application from "../common/Application";
import ExtensionData from "./utils/ExtensionData";

View File

@@ -1,11 +1,11 @@
declare var _default: {
extend: typeof import("../common/extend");
extend: any;
Session: typeof import("../common/Session").default;
Store: typeof import("../common/Store").default;
'utils/BasicEditorDriver': typeof import("../common/utils/BasicEditorDriver").default;
'utils/evented': {
handlers: Object;
getHandlers(event: string): any[];
handlers: Record<string, unknown>;
getHandlers(event: string): Function[];
trigger(event: string, ...args: any[]): void;
on(event: string, handler: Function): void;
one(event: string, handler: Function): void;
@@ -32,17 +32,15 @@ declare var _default: {
'utils/subclassOf': typeof import("../common/utils/subclassOf").default;
'utils/setRouteWithForcedRefresh': typeof import("../common/utils/setRouteWithForcedRefresh").default;
'utils/patchMithril': typeof import("../common/utils/patchMithril").default;
'utils/proxifyCompat': (compat: {
[key: string]: any;
}, namespace: string) => {
[key: string]: any;
};
'utils/proxifyCompat': typeof import("../common/utils/proxifyCompat").default;
'utils/classList': (...classes: import("clsx").ClassValue[]) => string;
'utils/extractText': typeof import("../common/utils/extractText").default;
'utils/formatNumber': typeof import("../common/utils/formatNumber").default;
'utils/mapRoutes': typeof import("../common/utils/mapRoutes").default;
'utils/withAttr': (key: string, cb: Function) => (this: Element) => void;
'utils/throttleDebounce': typeof import("../common/utils/throttleDebounce");
'utils/isObject': typeof import("../common/utils/isObject").default;
'utils/focusTrap': typeof import("../common/utils/focusTrap");
'models/Notification': typeof import("../common/models/Notification").default;
'models/User': typeof import("../common/models/User").default;
'models/Post': typeof import("../common/models/Post").default;
@@ -69,6 +67,7 @@ declare var _default: {
'components/Link': typeof import("../common/components/Link").default;
'components/LinkButton': typeof import("../common/components/LinkButton").default;
'components/Checkbox': typeof import("../common/components/Checkbox").default;
'components/ColorPreviewInput': typeof import("../common/components/ColorPreviewInput").default;
'components/SelectDropdown': typeof import("../common/components/SelectDropdown").default;
'components/ModalManager': typeof import("../common/components/ModalManager").default;
'components/Button': typeof import("../common/components/Button").default;

View File

@@ -5,10 +5,10 @@ export default class AdminNav extends Component<import("../../common/Component")
/**
* Build an item list of main links to show in the admin navigation.
*
* @return {ItemList}
* @return {ItemList<import('mithril').Children>}
*/
items(): ItemList;
extensionItems(): ItemList;
items(): ItemList<import('mithril').Children>;
extensionItems(): ItemList<any>;
}
import Component from "../../common/Component";
import Stream from "../../common/utils/Stream";

View File

@@ -0,0 +1,167 @@
import type Mithril from 'mithril';
import Page, { IPageAttrs } from '../../common/components/Page';
import Stream from '../../common/utils/Stream';
export interface AdminHeaderOptions {
title: Mithril.Children;
description: Mithril.Children;
icon: string;
/**
* Will be used as the class for the AdminPage.
*
* Will also be appended with `-header` and set as the class for the `AdminHeader` component.
*/
className: string;
}
/**
* A type that matches any valid value for the `type` attribute on an HTML `<input>` element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type
*
* Note: this will be exported from a different location in the future.
*
* @see https://github.com/flarum/core/issues/3039
*/
export declare type HTMLInputTypes = 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week';
interface CommonSettingsItemOptions extends Mithril.Attributes {
setting: string;
label: Mithril.Children;
help?: Mithril.Children;
className?: string;
}
/**
* Valid options for the setting component builder to generate an HTML input element.
*/
export interface HTMLInputSettingsComponentOptions extends CommonSettingsItemOptions {
/**
* Any valid HTML input `type` value.
*/
type: HTMLInputTypes;
}
declare const BooleanSettingTypes: readonly ["bool", "checkbox", "switch", "boolean"];
declare const SelectSettingTypes: readonly ["select", "dropdown", "selectdropdown"];
declare const TextareaSettingTypes: readonly ["textarea"];
declare const ColorPreviewSettingType = "color-preview";
/**
* Valid options for the setting component builder to generate a Switch.
*/
export interface SwitchSettingComponentOptions extends CommonSettingsItemOptions {
type: typeof BooleanSettingTypes[number];
}
/**
* Valid options for the setting component builder to generate a Select dropdown.
*/
export interface SelectSettingComponentOptions extends CommonSettingsItemOptions {
type: typeof SelectSettingTypes[number];
/**
* Map of values to their labels
*/
options: {
[value: string]: Mithril.Children;
};
default: string;
}
/**
* Valid options for the setting component builder to generate a Textarea.
*/
export interface TextareaSettingComponentOptions extends CommonSettingsItemOptions {
type: typeof TextareaSettingTypes[number];
}
/**
* Valid options for the setting component builder to generate a ColorPreviewInput.
*/
export interface ColorPreviewSettingComponentOptions extends CommonSettingsItemOptions {
type: typeof ColorPreviewSettingType;
}
/**
* All valid options for the setting component builder.
*/
export declare type SettingsComponentOptions = HTMLInputSettingsComponentOptions | SwitchSettingComponentOptions | SelectSettingComponentOptions | TextareaSettingComponentOptions | ColorPreviewSettingComponentOptions;
/**
* Valid attrs that can be returned by the `headerInfo` function
*/
export declare type AdminHeaderAttrs = AdminHeaderOptions & Partial<Omit<Mithril.Attributes, 'class'>>;
export default abstract class AdminPage<CustomAttrs extends IPageAttrs = IPageAttrs> extends Page<CustomAttrs> {
settings: Record<string, Stream<string>>;
loading: boolean;
view(vnode: Mithril.Vnode<CustomAttrs, this>): Mithril.Children;
/**
* Returns the content of the AdminPage.
*/
abstract content(vnode: Mithril.Vnode<CustomAttrs, this>): Mithril.Children;
/**
* Returns the submit button for this AdminPage.
*
* Calls `this.saveSettings` when the button is clicked.
*/
submitButton(vnode: Mithril.Vnode<CustomAttrs, this>): Mithril.Children;
/**
* Returns the Header component for this AdminPage.
*/
header(vnode: Mithril.Vnode<CustomAttrs, this>): Mithril.Children;
/**
* Returns the options passed to the AdminHeader component.
*/
headerInfo(): AdminHeaderAttrs;
/**
* `buildSettingComponent` takes a settings object and turns it into a component.
* Depending on the type of input, you can set the type to 'bool', 'select', or
* any standard <input> type. Any values inside the 'extra' object will be added
* to the component as an attribute.
*
* Alternatively, you can pass a callback that will be executed in ExtensionPage's
* context to include custom JSX elements.
*
* @example
*
* {
* setting: 'acme.checkbox',
* label: app.translator.trans('acme.admin.setting_label'),
* type: 'bool',
* help: app.translator.trans('acme.admin.setting_help'),
* className: 'Setting-item'
* }
*
* @example
*
* {
* setting: 'acme.select',
* label: app.translator.trans('acme.admin.setting_label'),
* type: 'select',
* options: {
* 'option1': 'Option 1 label',
* 'option2': 'Option 2 label',
* },
* default: 'option1',
* }
*
* @example
*
* () => {
* return <p>My cool component</p>;
* }
*/
buildSettingComponent(entry: ((this: this) => Mithril.Children) | SettingsComponentOptions): Mithril.Children;
/**
* Called when `saveSettings` completes successfully.
*/
onsaved(): void;
/**
* Returns a function that fetches the setting from the `app` global.
*/
setting(key: string, fallback?: string): Stream<string>;
/**
* Returns a map of settings keys to values which includes only those which have been modified but not yet saved.
*/
dirty(): Record<string, string>;
/**
* Returns the number of settings that have been modified.
*/
isChanged(): number;
/**
* Saves the modified settings to the database.
*/
saveSettings(e: SubmitEvent & {
redraw: boolean;
}): Promise<void>;
}
export {};

View File

@@ -1,4 +1,6 @@
export default class AppearancePage extends AdminPage<import("../../common/components/Page").IPageAttrs> {
constructor();
colorItems(): ItemList<any>;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -7,10 +7,12 @@ export default class BasicsPage extends AdminPage<import("../../common/component
* Build a list of options for the default homepage. Each option must be an
* object with `path` and `label` properties.
*
* @return {ItemList}
* @public
* @return {ItemList<{ path: string, label: import('mithril').Children }>}
*/
public homePageItems(): ItemList;
homePageItems(): ItemList<{
path: string;
label: import('mithril').Children;
}>;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -1,6 +1,6 @@
export default class DashboardPage extends AdminPage<import("../../common/components/Page").IPageAttrs> {
constructor();
availableWidgets(): ItemList;
availableWidgets(): ItemList<any>;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -3,14 +3,14 @@ export default class DashboardWidget extends Component<import("../../common/Comp
/**
* Get the class name to apply to the widget.
*
* @return {String}
* @return {string}
*/
className(): string;
/**
* Get the content of the widget.
*
* @return {VirtualElement}
* @return {import('mithril').Children}
*/
content(): any;
content(): import('mithril').Children;
}
import Component from "../../common/Component";

View File

@@ -2,14 +2,15 @@
* The `EditGroupModal` component shows a modal dialog which allows the user
* to create or edit a group.
*/
export default class EditGroupModal extends Modal {
export default class EditGroupModal extends Modal<import("../../common/components/Modal").IInternalModalAttrs> {
constructor();
group: any;
nameSingular: Stream<any> | undefined;
namePlural: Stream<any> | undefined;
icon: Stream<any> | undefined;
color: Stream<any> | undefined;
isHidden: Stream<any> | undefined;
fields(): ItemList;
fields(): ItemList<any>;
submitData(): {
nameSingular: any;
namePlural: any;

View File

@@ -1,5 +1,5 @@
export default class ExtensionLinkButton extends LinkButton {
statusItems(name: any): ItemList;
statusItems(name: any): ItemList<any>;
}
import LinkButton from "../../common/components/LinkButton";
import ItemList from "../../common/utils/ItemList";

View File

@@ -1,7 +1,15 @@
export default class ExtensionPage extends AdminPage<import("../../common/components/Page").IPageAttrs> {
constructor();
extension: any;
changingState: boolean | undefined;
import ItemList from '../../common/utils/ItemList';
import AdminPage from './AdminPage';
import RequestError from '../../common/utils/RequestError';
import { Extension } from '../AdminApplication';
import { IPageAttrs } from '../../common/components/Page';
import type Mithril from 'mithril';
export interface ExtensionPageAttrs extends IPageAttrs {
id: string;
}
export default class ExtensionPage<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs> extends AdminPage<Attrs> {
extension: Extension;
changingState: boolean;
infoFields: {
discuss: string;
documentation: string;
@@ -9,14 +17,16 @@ export default class ExtensionPage extends AdminPage<import("../../common/compon
website: string;
donate: string;
source: string;
} | undefined;
};
oninit(vnode: Mithril.Vnode<Attrs, this>): void;
className(): string;
sections(): ItemList;
topItems(): ItemList;
infoItems(): ItemList;
view(vnode: Mithril.VnodeDOM<Attrs, this>): JSX.Element | null;
header(): JSX.Element[];
sections(vnode: Mithril.VnodeDOM<Attrs, this>): ItemList<unknown>;
content(vnode: Mithril.VnodeDOM<Attrs, this>): JSX.Element;
topItems(): ItemList<Mithril.Children>;
infoItems(): ItemList<Mithril.Children>;
toggle(): void;
isEnabled(): any;
onerror(e: any): void;
onerror(e: RequestError): void;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -1,4 +1,19 @@
export default class ExtensionPermissionGrid extends PermissionGrid {
extensionId: any;
import PermissionGrid, { PermissionGridEntry } from './PermissionGrid';
import ItemList from '../../common/utils/ItemList';
import Mithril from 'mithril';
export interface IExtensionPermissionGridAttrs {
extensionId: string;
}
export default class ExtensionPermissionGrid<CustomAttrs extends IExtensionPermissionGridAttrs = IExtensionPermissionGridAttrs> extends PermissionGrid<CustomAttrs> {
protected extensionId: string;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
permissionItems(): ItemList<{
label: Mithril.Children;
children: PermissionGridEntry[];
}>;
viewItems(): ItemList<import("./PermissionGrid").PermissionConfig>;
startItems(): ItemList<import("./PermissionGrid").PermissionConfig>;
replyItems(): ItemList<import("./PermissionGrid").PermissionConfig>;
moderateItems(): ItemList<import("./PermissionGrid").PermissionConfig>;
scopeControlItems(): ItemList<unknown>;
}
import PermissionGrid from "./PermissionGrid";

View File

@@ -8,9 +8,9 @@ export default class HeaderPrimary extends Component<import("../../common/Compon
/**
* Build an item list for the controls.
*
* @return {ItemList}
* @return {ItemList<import('mithril').Children>}
*/
items(): ItemList;
items(): ItemList<import('mithril').Children>;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -6,9 +6,9 @@ export default class HeaderSecondary extends Component<import("../../common/Comp
/**
* Build an item list for the controls.
*
* @return {ItemList}
* @return {ItemList<import('mithril').Children>}
*/
items(): ItemList;
items(): ItemList<import('mithril').Children>;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -1,3 +1,14 @@
export default class LoadingModal extends Modal {
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
import Modal, { IInternalModalAttrs } from '../../common/components/Modal';
export interface ILoadingModalAttrs extends IInternalModalAttrs {
}
export default class LoadingModal<ModalAttrs extends ILoadingModalAttrs = ILoadingModalAttrs> extends Modal<ModalAttrs> {
/**
* @inheritdoc
*/
static readonly isDismissible: boolean;
className(): string;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): string;
onsubmit(e: Event): void;
}
import Modal from "../../common/components/Modal";

View File

@@ -1,12 +1,36 @@
export default class PermissionGrid extends Component<import("../../common/Component").ComponentAttrs, undefined> {
constructor();
permissionItems(): ItemList;
viewItems(): ItemList;
startItems(): ItemList;
replyItems(): ItemList;
moderateItems(): ItemList;
scopeItems(): ItemList;
scopeControlItems(): ItemList;
import Component, { ComponentAttrs } from '../../common/Component';
import ItemList from '../../common/utils/ItemList';
import type Mithril from 'mithril';
export interface PermissionConfig {
permission: string;
icon: string;
label: Mithril.Children;
allowGuest?: boolean;
}
export interface PermissionSetting {
setting: () => Mithril.Children;
icon: string;
label: Mithril.Children;
}
export declare type PermissionGridEntry = PermissionConfig | PermissionSetting;
export declare type PermissionType = 'view' | 'start' | 'reply' | 'moderate';
export interface ScopeItem {
label: Mithril.Children;
render: (permission: PermissionGridEntry) => Mithril.Children;
onremove?: () => void;
}
export interface IPermissionGridAttrs extends ComponentAttrs {
}
export default class PermissionGrid<CustomAttrs extends IPermissionGridAttrs = IPermissionGridAttrs> extends Component<CustomAttrs> {
view(vnode: Mithril.Vnode<CustomAttrs, this>): JSX.Element;
permissionItems(): ItemList<{
label: Mithril.Children;
children: PermissionGridEntry[];
}>;
viewItems(): ItemList<PermissionGridEntry>;
startItems(): ItemList<PermissionGridEntry>;
replyItems(): ItemList<PermissionGridEntry>;
moderateItems(): ItemList<PermissionGridEntry>;
scopeItems(): ItemList<ScopeItem>;
scopeControlItems(): ItemList<unknown>;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,18 @@
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
import Modal, { IInternalModalAttrs } from '../../common/components/Modal';
import ExtensionReadme from '../models/ExtensionReadme';
import type Mithril from 'mithril';
import type { Extension } from '../AdminApplication';
export interface IReadmeModalAttrs extends IInternalModalAttrs {
extension: Extension;
}
export default class ReadmeModal<CustomAttrs extends IReadmeModalAttrs = IReadmeModalAttrs> extends Modal<CustomAttrs> {
protected name: string;
protected extName: string;
protected readme: ExtensionReadme;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
className(): string;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): JSX.Element;
loadReadme(): Promise<void>;
}

View File

@@ -8,7 +8,7 @@ export default class SessionDropdown extends Dropdown {
*
* @return {ItemList}
*/
items(): ItemList;
items(): ItemList<any>;
}
import Dropdown from "../../common/components/Dropdown";
import ItemList from "../../common/utils/ItemList";

View File

@@ -1,4 +1,5 @@
export default class SettingsModal extends Modal {
export default class SettingsModal extends Modal<import("../../common/components/Modal").IInternalModalAttrs> {
constructor();
settings: {} | undefined;
form(): string;
submitButton(): JSX.Element;

View File

@@ -1,5 +1,6 @@
export default class StatusWidget extends DashboardWidget {
items(): ItemList;
items(): ItemList<any>;
toolsItems(): ItemList<any>;
handleClearCache(e: any): void;
}
import DashboardWidget from "./DashboardWidget";

View File

@@ -13,16 +13,16 @@ export default class UploadImageButton extends Button<import("../../common/compo
/**
* After a successful upload/removal, reload the page.
*
* @param {Object} response
* @param {object} response
* @protected
*/
protected success(response: Object): void;
protected success(response: object): void;
/**
* If upload/removal fails, stop loading.
*
* @param {Object} response
* @param {object} response
* @protected
*/
protected failure(response: Object): void;
protected failure(response: object): void;
}
import Button from "../../common/components/Button";

View File

@@ -1,6 +1,18 @@
/// <reference types="mithril" />
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
import type Mithril from 'mithril';
import type User from '../../common/models/User';
import ItemList from '../../common/utils/ItemList';
import AdminPage from './AdminPage';
declare type ColumnData = {
/**
* Column title
*/
name: Mithril.Children;
/**
* Component(s) to show for this column.
*/
content: (user: User) => Mithril.Children;
};
/**
* Admin page which displays a paginated list of all users on the forum.
*/
@@ -50,12 +62,12 @@ export default class UserListPage extends AdminPage {
*
* See `UserListPage.tsx` for examples.
*/
columns(): ItemList;
columns(): ItemList<ColumnData>;
headerInfo(): {
className: string;
icon: string;
title: any;
description: any;
title: import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
description: import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
};
/**
* Asynchronously fetch the next set of users to be rendered.
@@ -70,3 +82,4 @@ export default class UserListPage extends AdminPage {
nextPage(): void;
previousPage(): void;
}
export {};

View File

@@ -1,5 +1,3 @@
import app from './app';
export { app };
export declare const compat: {
[key: string]: any;
};
export declare const compat: Record<string, unknown>;

View File

@@ -0,0 +1,4 @@
export default class ExtensionReadme extends Model {
content: () => any;
}
import Model from "../../common/Model";

View File

@@ -1,9 +1,10 @@
import DefaultResolver from '../../common/resolvers/DefaultResolver';
import ExtensionPage, { ExtensionPageAttrs } from '../components/ExtensionPage';
/**
* A custom route resolver for ExtensionPage that generates handles routes
* to default extension pages or a page provided by an extension.
*/
export default class ExtensionPageResolver extends DefaultResolver {
export default class ExtensionPageResolver<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs, RouteArgs extends Record<string, unknown> = {}> extends DefaultResolver<Attrs, ExtensionPage<Attrs>, RouteArgs> {
static extension: string | null;
onmatch(args: any, requestedPath: any, route: any): any;
onmatch(args: Attrs & RouteArgs, requestedPath: string, route: string): new () => ExtensionPage<Attrs>;
}

View File

@@ -1,6 +1,5 @@
import AdminApplication from './AdminApplication';
/**
* The `routes` initializer defines the forum app's routes.
*
* @param {App} app
*/
export default function _default(app: any): void;
export default function (app: AdminApplication): void;

View File

@@ -1,17 +1,46 @@
import type Mithril from 'mithril';
import ItemList from '../../common/utils/ItemList';
import { SettingsComponentOptions } from '../components/AdminPage';
import ExtensionPage, { ExtensionPageAttrs } from '../components/ExtensionPage';
import { PermissionConfig, PermissionType } from '../components/PermissionGrid';
declare type SettingConfigInput = SettingsComponentOptions | (() => Mithril.Children);
declare type SettingConfigInternal = SettingsComponentOptions | ((() => Mithril.Children) & {
setting: string;
});
export declare type CustomExtensionPage<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs> = new () => ExtensionPage<Attrs>;
declare type ExtensionConfig = {
settings?: ItemList<SettingConfigInternal>;
permissions?: {
view?: ItemList<PermissionConfig>;
start?: ItemList<PermissionConfig>;
reply?: ItemList<PermissionConfig>;
moderate?: ItemList<PermissionConfig>;
};
page?: CustomExtensionPage;
};
declare type InnerDataNoActiveExtension = {
currentExtension: null;
data: {
[key: string]: ExtensionConfig | undefined;
};
};
declare type InnerDataActiveExtension = {
currentExtension: string;
data: {
[key: string]: ExtensionConfig;
};
};
export default class ExtensionData {
data: {};
currentExtension: any;
protected state: InnerDataActiveExtension | InnerDataNoActiveExtension;
/**
* This function simply takes the extension id
*
* @example
* app.extensionData.load('flarum-tags')
* app.extensionData.for('flarum-tags')
*
* flarum/flags -> flarum-flags | acme/extension -> acme-extension
*
* @param extension
*/
for(extension: any): ExtensionData;
for(extension: string): this;
/**
* This function registers your settings with Flarum
*
@@ -24,13 +53,8 @@ export default class ExtensionData {
* type: 'text', // This will be inputted into the input tag for the setting (text/number/etc)
* label: app.translator.trans('flarum-flags.admin.settings.guidelines_url_label')
* }, 15) // priority is optional (ItemList)
*
*
* @param content
* @param priority
* @returns {ExtensionData}
*/
registerSetting(content: any, priority?: number): ExtensionData;
registerSetting(content: SettingConfigInput, priority?: number): this;
/**
* This function registers your permission with Flarum
*
@@ -41,58 +65,32 @@ export default class ExtensionData {
* label: app.translator.trans('flarum-flags.admin.permissions.view_flags_label'),
* permission: 'discussion.viewFlags'
* }, 'moderate', 65)
*
* @param content
* @param permissionType
* @param priority
* @returns {ExtensionData}
*/
registerPermission(content: any, permissionType?: any, priority?: number): ExtensionData;
registerPermission(content: PermissionConfig, permissionType: PermissionType, priority?: number): this;
/**
* Replace the default extension page with a custom component.
* This component would typically extend ExtensionPage
*
* @param component
* @returns {ExtensionData}
*/
registerPage(component: any): ExtensionData;
registerPage(component: CustomExtensionPage): this;
/**
* Get an extension's registered settings
*
* @param extensionId
* @returns {boolean|*}
*/
getSettings(extensionId: any): boolean | any;
getSettings(extensionId: string): SettingConfigInternal[] | undefined;
/**
*
* Get an ItemList of all extensions' registered permissions
*
* @param extension
* @param type
* @returns {ItemList}
*/
getAllExtensionPermissions(type: any): ItemList;
getAllExtensionPermissions(type: PermissionType): ItemList<PermissionConfig>;
/**
* Get a singular extension's registered permissions
*
* @param extension
* @param type
* @returns {boolean|*}
*/
getExtensionPermissions(extension: any, type: any): boolean | any;
getExtensionPermissions(extension: string, type: PermissionType): ItemList<PermissionConfig>;
/**
* Checks whether a given extension has registered permissions.
*
* @param extension
* @returns {boolean}
*/
extensionHasPermissions(extension: any): boolean;
extensionHasPermissions(extension: string): boolean;
/**
* Returns an extension's custom page component if it exists.
*
* @param extension
* @returns {boolean|*}
*/
getPage(extension: any): boolean | any;
getPage<Attrs extends ExtensionPageAttrs = ExtensionPageAttrs>(extension: string): CustomExtensionPage<Attrs> | undefined;
}
import ItemList from "../../common/utils/ItemList";
export {};

View File

@@ -1,3 +1,96 @@
import ItemList from './utils/ItemList';
import Translator from './Translator';
import Store, { ApiPayload, ApiResponsePlural, ApiResponseSingle } from './Store';
import Session from './Session';
import Drawer from './utils/Drawer';
import RequestError, { InternalFlarumRequestOptions } from './utils/RequestError';
import Forum from './models/Forum';
import PageState from './states/PageState';
import ModalManagerState from './states/ModalManagerState';
import AlertManagerState from './states/AlertManagerState';
import type DefaultResolver from './resolvers/DefaultResolver';
import type Mithril from 'mithril';
import type Component from './Component';
import type { ComponentAttrs } from './Component';
import Model, { SavedModelData } from './Model';
export declare type FlarumScreens = 'phone' | 'tablet' | 'desktop' | 'desktop-hd';
export declare type FlarumGenericRoute = RouteItem<any, any, any>;
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
errorHandler?: (error: RequestError) => void;
url: string;
/**
* Manipulate the response text before it is parsed into JSON.
*
* @deprecated Please use `modifyText` instead.
*/
extract?: (responseText: string) => string;
/**
* Manipulate the response text before it is parsed into JSON.
*
* This overrides any `extract` method provided.
*/
modifyText?: (responseText: string) => string;
}
/**
* A valid route definition.
*/
export declare type RouteItem<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
routeName: string;
}>, RouteArgs extends Record<string, unknown> = {}> = {
/**
* The path for your route.
*
* This might be a specific URL path (e.g.,`/myPage`), or it might
* contain a variable used by a resolver (e.g., `/myPage/:id`).
*
* @see https://docs.flarum.org/extend/frontend-pages.html#route-resolvers-advanced
*/
path: `/${string}`;
} & ({
/**
* The component to render when this route matches.
*/
component: new () => Comp;
/**
* A custom resolver class.
*
* This should be the class itself, and **not** an instance of the
* class.
*/
resolverClass?: new (component: new () => Comp, routeName: string) => DefaultResolver<Attrs, Comp, RouteArgs>;
} | {
/**
* An instance of a route resolver.
*/
resolver: RouteResolver<Attrs, Comp, RouteArgs>;
});
export interface RouteResolver<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
routeName: string;
}>, RouteArgs extends Record<string, unknown> = {}> {
/**
* A method which selects which component to render based on
* conditional logic.
*
* Returns the component class, and **not** a Vnode or JSX
* expression.
*
* @see https://mithril.js.org/route.html#routeresolveronmatch
*/
onmatch(this: this, args: RouteArgs, requestedPath: string, route: string): {
new (): Comp;
};
/**
* A function which renders the provided component.
*
* If not specified, the route will default to rendering the
* component on its own, inside of a fragment.
*
* Returns a Mithril Vnode or other children.
*
* @see https://mithril.js.org/route.html#routeresolverrender
*/
render?(this: this, vnode: Mithril.Vnode<Attrs, Comp>): Mithril.Children;
}
/**
* The `App` class provides a container for an application, as well as various
* utilities for the rest of the app to use.
@@ -5,11 +98,8 @@
export default class Application {
/**
* The forum model for this application.
*
* @type {Forum}
* @public
*/
public forum: Forum;
forum: Forum;
/**
* A map of routes, keyed by a unique route name. Each route is an object
* containing the following properties:
@@ -18,71 +108,42 @@ export default class Application {
* - `component` The Mithril component to render when this route is active.
*
* @example
* app.routes.discussion = {path: '/d/:id', component: DiscussionPage.component()};
*
* @type {Object}
* @public
* app.routes.discussion = { path: '/d/:id', component: DiscussionPage };
*/
public routes: Object;
routes: Record<string, FlarumGenericRoute>;
/**
* An ordered list of initializers to bootstrap the application.
*
* @type {ItemList}
* @public
*/
public initializers: ItemList;
initializers: ItemList<(app: this) => void>;
/**
* The app's session.
*
* @type {Session}
* @public
* Stores info about the current user.
*/
public session: Session;
session: Session;
/**
* The app's translator.
*
* @type {Translator}
* @public
*/
public translator: Translator;
translator: Translator;
/**
* The app's data store.
*
* @type {Store}
* @public
*/
public store: Store;
store: Store;
/**
* A local cache that can be used to store data at the application level, so
* that is persists between different routes.
*
* @type {Object}
* @public
*/
public cache: Object;
cache: Record<string, unknown>;
/**
* Whether or not the app has been booted.
*
* @type {Boolean}
* @public
*/
public booted: boolean;
/**
* The key for an Alert that was shown as a result of an AJAX request error.
* If present, it will be dismissed on the next successful request.
*
* @type {int}
* @private
*/
private requestErrorAlert;
booted: boolean;
/**
* The page the app is currently on.
*
* This object holds information about the type of page we are currently
* visiting, and sometimes additional arbitrary page state that may be
* relevant to lower-level components.
*
* @type {PageState}
*/
current: PageState;
/**
@@ -91,84 +152,86 @@ export default class Application {
* Once the application navigates to another page, the object previously
* assigned to this.current will be moved to this.previous, while this.current
* is re-initialized.
*
* @type {PageState}
*/
previous: PageState;
/**
* An object that manages modal state.
*/
modal: ModalManagerState;
/**
* An object that manages the state of active alerts.
*
* @type {AlertManagerState}
*/
alerts: AlertManagerState;
data: any;
title: string;
titleCount: number;
initialRoute: any;
load(payload: any): void;
/**
* An object that manages the state of the navigation drawer.
*/
drawer: Drawer;
data: {
apiDocument: ApiPayload | null;
locale: string;
locales: Record<string, string>;
resources: SavedModelData[];
session: {
userId: number;
csrfToken: string;
};
[key: string]: unknown;
};
private _title;
private _titleCount;
private set title(value);
get title(): string;
private set titleCount(value);
get titleCount(): number;
/**
* The key for an Alert that was shown as a result of an AJAX request error.
* If present, it will be dismissed on the next successful request.
*/
private requestErrorAlert;
initialRoute: string;
load(payload: Application['data']): void;
boot(): void;
bootExtensions(extensions: any): void;
mount(basePath?: string): void;
drawer: Drawer | undefined;
bootExtensions(extensions: Record<string, {
extend?: unknown[];
}>): void;
protected mount(basePath?: string): void;
/**
* Get the API response document that has been preloaded into the application.
*
* @return {Object|null}
* @public
*/
public preloadedApiDocument(): Object | null;
preloadedApiDocument<M extends Model>(): ApiResponseSingle<M> | null;
preloadedApiDocument<Ms extends Model[]>(): ApiResponsePlural<Ms[number]> | null;
/**
* Determine the current screen mode, based on our media queries.
*
* @returns {String} - one of "phone", "tablet", "desktop" or "desktop-hd"
*/
screen(): string;
screen(): FlarumScreens;
/**
* Set the <title> of the page.
* Set the `<title>` of the page.
*
* @param {String} title
* @public
* @param title New page title
*/
public setTitle(title: string): void;
setTitle(title: string): void;
/**
* Set a number to display in the <title> of the page.
* Set a number to display in the `<title>` of the page.
*
* @param {Integer} count
* @param count Number to display in title
*/
setTitleCount(count: any): void;
setTitleCount(count: number): void;
updateTitle(): void;
protected transformRequestOptions<ResponseType>(flarumOptions: FlarumRequestOptions<ResponseType>): InternalFlarumRequestOptions<ResponseType>;
/**
* Make an AJAX request, handling any low-level errors that may occur.
*
* @see https://mithril.js.org/request.html
* @param {Object} options
* @return {Promise}
* @public
*/
public request(originalOptions: any): Promise<any>;
request<ResponseType>(originalOptions: FlarumRequestOptions<ResponseType>): Promise<ResponseType>;
/**
* @param {RequestError} error
* @param {string[]} [formattedError]
* @private
* By default, show an error alert, and log the error to the console.
*/
protected requestErrorCatch<ResponseType>(error: RequestError, customErrorHandler: FlarumRequestOptions<ResponseType>['errorHandler']): Promise<never>;
protected requestErrorDefaultHandler(e: unknown, isDebug: boolean, formattedErrors: string[]): void;
private showDebug;
/**
* Construct a URL to the route with the given name.
*
* @param {String} name
* @param {Object} params
* @return {String}
* @public
*/
public route(name: string, params?: Object): string;
route(name: string, params?: Record<string, unknown>): string;
}
import Forum from "./models/Forum";
import ItemList from "./utils/ItemList";
import Session from "./Session";
import Translator from "./Translator";
import Store from "./Store";
import PageState from "./states/PageState";
import ModalManagerState from "./states/ModalManagerState";
import AlertManagerState from "./states/AlertManagerState";
import Drawer from "./utils/Drawer";

View File

@@ -99,7 +99,7 @@ export default abstract class Component<Attrs extends ComponentAttrs = Component
*
* @see https://mithril.js.org/hyperscript.html#mselector,-attributes,-children
*/
static component(attrs?: {}, children?: null): Mithril.Vnode;
static component<SAttrs extends ComponentAttrs = ComponentAttrs>(attrs?: SAttrs, children?: Mithril.Children): Mithril.Vnode;
/**
* Saves a reference to the vnode attrs after running them through initAttrs,
* and checking for common issues.

View File

@@ -28,11 +28,11 @@ export default abstract class Fragment {
* containing all of the `li` elements inside the DOM element of this
* fragment.
*
* @param {String} [selector] a jQuery-compatible selector string
* @returns {jQuery} the jQuery object for the DOM node
* @param [selector] a jQuery-compatible selector string
* @returns the jQuery object for the DOM node
* @final
*/
$(selector: any): JQuery<any>;
$(selector?: string): JQuery;
/**
* Get the renderable virtual DOM that represents the fragment's view.
*

View File

@@ -1,149 +1,147 @@
import { FlarumRequestOptions } from './Application';
import Store, { ApiPayloadSingle, ApiResponseSingle, MetaInformation } from './Store';
export interface ModelIdentifier {
type: string;
id: string;
}
export interface ModelAttributes {
[key: string]: unknown;
}
export interface ModelRelationships {
[relationship: string]: {
data: ModelIdentifier | ModelIdentifier[];
};
}
export interface UnsavedModelData {
type?: string;
attributes?: ModelAttributes;
relationships?: ModelRelationships;
}
export interface SavedModelData {
type: string;
id: string;
attributes?: ModelAttributes;
relationships?: ModelRelationships;
}
export declare type ModelData = UnsavedModelData | SavedModelData;
export interface SaveRelationships {
[relationship: string]: Model | Model[];
}
export interface SaveAttributes {
[key: string]: unknown;
relationships?: SaveRelationships;
}
/**
* The `Model` class represents a local data resource. It provides methods to
* persist changes via the API.
*
* @abstract
*/
export default class Model {
/**
* Generate a function which returns the value of the given attribute.
*
* @param {String} name
* @param {function} [transform] A function to transform the attribute value
* @return {*}
* @public
*/
public static attribute(name: string, transform?: Function | undefined): any;
/**
* Generate a function which returns the value of the given has-one
* relationship.
*
* @param {String} name
* @return {Model|Boolean|undefined} false if no information about the
* relationship exists; undefined if the relationship exists but the model
* has not been loaded; or the model if it has been loaded.
* @public
*/
public static hasOne(name: string): Model | boolean | undefined;
/**
* Generate a function which returns the value of the given has-many
* relationship.
*
* @param {String} name
* @return {Array|Boolean} false if no information about the relationship
* exists; an array if it does, containing models if they have been
* loaded, and undefined for those that have not.
* @public
*/
public static hasMany(name: string): any[] | boolean;
/**
* Transform the given value into a Date object.
*
* @param {String} value
* @return {Date|null}
* @public
*/
public static transformDate(value: string): Date | null;
/**
* Get a resource identifier object for the given model.
*
* @param {Model} model
* @return {Object}
* @protected
*/
protected static getIdentifier(model: Model): Object;
/**
* @param {Object} data A resource object from the API.
* @param {Store} store The data store that this model should be persisted to.
* @public
*/
constructor(data?: Object, store?: any);
export default abstract class Model {
/**
* The resource object from the API.
*
* @type {Object}
* @public
*/
public data: Object;
data: ModelData;
/**
* The time at which the model's data was last updated. Watching the value
* of this property is a fast way to retain/cache a subtree if data hasn't
* changed.
*
* @type {Date}
* @public
*/
public freshness: Date;
freshness: Date;
/**
* Whether or not the resource exists on the server.
*
* @type {Boolean}
* @public
*/
public exists: boolean;
exists: boolean;
/**
* The data store that this resource should be persisted to.
*
* @type {Store}
* @protected
*/
protected store: any;
protected store: Store;
/**
* @param data A resource object from the API.
* @param store The data store that this model should be persisted to.
*/
constructor(data?: ModelData, store?: Store);
/**
* Get the model's ID.
*
* @return {Integer}
* @public
* @final
*/
public id(): any;
id(): string | undefined;
/**
* Get one of the model's attributes.
*
* @param {String} attribute
* @return {*}
* @public
* @final
*/
public attribute(attribute: string): any;
attribute<T = unknown>(attribute: string): T;
/**
* Merge new data into this model locally.
*
* @param {Object} data A resource object to merge into this model
* @public
* @param data A resource object to merge into this model
*/
public pushData(data: Object): void;
pushData(data: ModelData | {
relationships?: SaveRelationships;
}): this;
/**
* Merge new attributes into this model locally.
*
* @param {Object} attributes The attributes to merge.
* @public
* @param attributes The attributes to merge.
*/
public pushAttributes(attributes: Object): void;
pushAttributes(attributes: ModelAttributes): void;
/**
* Merge new attributes into this model, both locally and with persistence.
*
* @param {Object} attributes The attributes to save. If a 'relationships' key
* @param attributes The attributes to save. If a 'relationships' key
* exists, it will be extracted and relationships will also be saved.
* @param {Object} [options]
* @return {Promise}
* @public
*/
public save(attributes: Object, options?: Object | undefined): Promise<any>;
save(attributes: SaveAttributes, options?: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & {
meta?: MetaInformation;
}): Promise<ApiResponseSingle<this>>;
/**
* Send a request to delete the resource.
*
* @param {Object} body Data to send along with the DELETE request.
* @param {Object} [options]
* @return {Promise}
* @public
* @param body Data to send along with the DELETE request.
*/
public delete(body: Object, options?: Object | undefined): Promise<any>;
delete(body?: FlarumRequestOptions<void>['body'], options?: Omit<FlarumRequestOptions<void>, 'url'>): Promise<void>;
/**
* Construct a path to the API endpoint for this resource.
*
* @return {String}
* @protected
*/
protected apiEndpoint(): string;
copyData(): any;
protected copyData(): ModelData;
protected rawRelationship<M extends Model>(relationship: string): undefined | ModelIdentifier;
protected rawRelationship<M extends Model[]>(relationship: string): undefined | ModelIdentifier[];
/**
* Generate a function which returns the value of the given attribute.
*
* @param transform A function to transform the attribute value
*/
static attribute<T>(name: string): () => T;
static attribute<T, O = unknown>(name: string, transform: (attr: O) => T): () => T;
/**
* Generate a function which returns the value of the given has-one
* relationship.
*
* @return false if no information about the
* relationship exists; undefined if the relationship exists but the model
* has not been loaded; or the model if it has been loaded.
*/
static hasOne<M extends Model>(name: string): () => M | false;
static hasOne<M extends Model | null>(name: string): () => M | null | false;
/**
* Generate a function which returns the value of the given has-many
* relationship.
*
* @return false if no information about the relationship
* exists; an array if it does, containing models if they have been
* loaded, and undefined for those that have not.
*/
static hasMany<M extends Model>(name: string): () => (M | undefined)[] | false;
/**
* Transform the given value into a Date object.
*/
static transformDate(value: string): Date;
static transformDate(value: string | null): Date | null;
static transformDate(value: string | undefined): Date | undefined;
static transformDate(value: string | null | undefined): Date | null | undefined;
/**
* Get a resource identifier object for the given model.
*/
protected static getIdentifier(model: Model): ModelIdentifier;
}

View File

@@ -1,37 +1,33 @@
import User from './models/User';
import { FlarumRequestOptions } from './Application';
export declare type LoginParams = {
/**
* The username/email
*/
identification: string;
password: string;
remember: boolean;
};
/**
* The `Session` class defines the current user session. It stores a reference
* to the current authenticated user, and provides methods to log in/out.
*/
export default class Session {
constructor(user: any, csrfToken: any);
/**
* The current authenticated user.
*
* @type {User|null}
* @public
*/
public user: any | null;
user: User | null;
/**
* The CSRF token.
*
* @type {String|null}
* @public
*/
public csrfToken: string | null;
csrfToken: string;
constructor(user: User | null, csrfToken: string);
/**
* Attempt to log in a user.
*
* @param {String} identification The username/email.
* @param {String} password
* @param {Object} [options]
* @return {Promise}
* @public
*/
public login(body: any, options?: Object | undefined): Promise<any>;
login(body: LoginParams, options?: Omit<FlarumRequestOptions<any>, 'url' | 'body' | 'method'>): Promise<any>;
/**
* Log the user out.
*
* @public
*/
public logout(): void;
logout(): void;
}

View File

@@ -1,97 +1,127 @@
import { FlarumRequestOptions } from './Application';
import Model, { ModelData, SavedModelData } from './Model';
export interface MetaInformation {
[key: string]: any;
}
export interface ApiQueryParamsSingle {
fields?: string[];
include?: string;
bySlug?: boolean;
meta?: MetaInformation;
}
export interface ApiQueryParamsPlural {
fields?: string[];
include?: string;
filter?: {
q: string;
[key: string]: string;
};
page?: {
offset?: number;
number?: number;
limit?: number;
size?: number;
};
sort?: string;
meta?: MetaInformation;
}
export declare type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
export interface ApiPayloadSingle {
data: SavedModelData;
included?: SavedModelData[];
meta?: MetaInformation;
}
export interface ApiPayloadPlural {
data: SavedModelData[];
included?: SavedModelData[];
links?: {
first: string;
next?: string;
prev?: string;
};
meta?: MetaInformation;
}
export declare type ApiPayload = ApiPayloadSingle | ApiPayloadPlural;
export declare type ApiResponseSingle<M extends Model> = M & {
payload: ApiPayloadSingle;
};
export declare type ApiResponsePlural<M extends Model> = M[] & {
payload: ApiPayloadPlural;
};
export declare type ApiResponse<M extends Model> = ApiResponseSingle<M> | ApiResponsePlural<M>;
interface ApiQueryRequestOptions<ResponseType> extends Omit<FlarumRequestOptions<ResponseType>, 'url'> {
}
interface StoreData {
[type: string]: Partial<Record<string, Model>>;
}
export declare function payloadIsPlural(payload: ApiPayload): payload is ApiPayloadPlural;
/**
* The `Store` class defines a local data store, and provides methods to
* retrieve data from the API.
*/
export default class Store {
constructor(models: any);
/**
* The local data store. A tree of resource types to IDs, such that
* accessing data[type][id] will return the model for that type/ID.
*
* @type {Object}
* @protected
*/
protected data: Object;
protected data: StoreData;
/**
* The model registry. A map of resource types to the model class that
* should be used to represent resources of that type.
*
* @type {Object}
* @public
*/
public models: Object;
models: Record<string, typeof Model>;
constructor(models: Record<string, typeof Model>);
/**
* Push resources contained within an API payload into the store.
*
* @param {Object} payload
* @return {Model|Model[]} The model(s) representing the resource(s) contained
* @return The model(s) representing the resource(s) contained
* within the 'data' key of the payload.
* @public
*/
public pushPayload(payload: Object): any | any[];
pushPayload<M extends Model>(payload: ApiPayloadSingle): ApiResponseSingle<M>;
pushPayload<Ms extends Model[]>(payload: ApiPayloadPlural): ApiResponsePlural<Ms[number]>;
/**
* Create a model to represent a resource object (or update an existing one),
* and push it into the store.
*
* @param {Object} data The resource object
* @return {Model|null} The model, or null if no model class has been
* @param data The resource object
* @return The model, or null if no model class has been
* registered for this resource type.
* @public
*/
public pushObject(data: Object): any | null;
pushObject<M extends Model>(data: SavedModelData): M | null;
pushObject<M extends Model>(data: SavedModelData, allowUnregistered: false): M;
/**
* Make a request to the API to find record(s) of a specific type.
*
* @param {String} type The resource type.
* @param {Integer|Integer[]|Object} [id] The ID(s) of the model(s) to retrieve.
* Alternatively, if an object is passed, it will be handled as the
* `query` parameter.
* @param {Object} [query]
* @param {Object} [options]
* @return {Promise}
* @public
*/
public find(type: string, id?: any | any[] | Object, query?: Object | undefined, options?: Object | undefined): Promise<any>;
find<M extends Model>(type: string, params: ApiQueryParamsSingle): Promise<ApiResponseSingle<M>>;
find<Ms extends Model[]>(type: string, params: ApiQueryParamsPlural): Promise<ApiResponsePlural<Ms[number]>>;
find<M extends Model>(type: string, id: string, params?: ApiQueryParamsSingle, options?: ApiQueryRequestOptions<ApiPayloadSingle>): Promise<ApiResponseSingle<M>>;
find<Ms extends Model[]>(type: string, ids: string[], params?: ApiQueryParamsPlural, options?: ApiQueryRequestOptions<ApiPayloadPlural>): Promise<ApiResponsePlural<Ms[number]>>;
/**
* Get a record from the store by ID.
*
* @param {String} type The resource type.
* @param {Integer} id The resource ID.
* @return {Model}
* @public
*/
public getById(type: string, id: any): any;
getById<M extends Model>(type: string, id: string): M | undefined;
/**
* Get a record from the store by the value of a model attribute.
*
* @param {String} type The resource type.
* @param {String} key The name of the method on the model.
* @param {*} value The value of the model attribute.
* @return {Model}
* @public
* @param type The resource type.
* @param key The name of the method on the model.
* @param value The value of the model attribute.
*/
public getBy(type: string, key: string, value: any): any;
getBy<M extends Model, T = unknown>(type: string, key: keyof M, value: T): M | undefined;
/**
* Get all loaded records of a specific type.
*
* @param {String} type
* @return {Model[]}
* @public
*/
public all(type: string): any[];
all<M extends Model>(type: string): M[];
/**
* Remove the given model from the store.
*
* @param {Model} model
*/
remove(model: any): void;
remove(model: Model): void;
/**
* Create a new record of the given type.
*
* @param {String} type The resource type
* @param {Object} [data] Any data to initialize the model with
* @return {Model}
* @public
* @param type The resource type
* @param data Any data to initialize the model with
*/
public createRecord(type: string, data?: Object | undefined): any;
createRecord<M extends Model>(type: string, data?: ModelData): M;
}
export {};

View File

@@ -1,3 +1,6 @@
/// <reference path="../../src/common/translator-icu-rich.d.ts" />
import { RichMessageFormatter } from '@askvortsov/rich-icu-message-formatter';
import { pluralTypeHandler, selectTypeHandler } from '@ultraq/icu-message-formatter';
declare type Translations = Record<string, string>;
declare type TranslatorParameters = Record<string, unknown>;
export default class Translator {
@@ -8,15 +11,15 @@ export default class Translator {
/**
* The underlying ICU MessageFormatter util.
*/
protected formatter: any;
protected formatter: RichMessageFormatter;
setLocale(locale: string): void;
addTranslations(translations: Translations): void;
/**
* An extensible entrypoint for extenders to register type handlers for translations.
*/
protected formatterTypeHandlers(): {
plural: any;
select: any;
plural: typeof pluralTypeHandler;
select: typeof selectTypeHandler;
};
/**
* A temporary system to preprocess parameters.
@@ -26,6 +29,6 @@ export default class Translator {
* @internal
*/
protected preprocessParameters(parameters: TranslatorParameters): TranslatorParameters;
trans(id: string, parameters?: TranslatorParameters): any;
trans(id: string, parameters?: TranslatorParameters): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
}
export {};

View File

@@ -1,11 +1,11 @@
declare var _default: {
extend: typeof extend;
extend: any;
Session: typeof Session;
Store: typeof Store;
'utils/BasicEditorDriver': typeof BasicEditorDriver;
'utils/evented': {
handlers: Object;
getHandlers(event: string): any[];
handlers: Record<string, unknown>;
getHandlers(event: string): Function[];
trigger(event: string, ...args: any[]): void;
on(event: string, handler: Function): void;
one(event: string, handler: Function): void;
@@ -32,17 +32,15 @@ declare var _default: {
'utils/subclassOf': typeof subclassOf;
'utils/setRouteWithForcedRefresh': typeof setRouteWithForcedRefresh;
'utils/patchMithril': typeof patchMithril;
'utils/proxifyCompat': (compat: {
[key: string]: any;
}, namespace: string) => {
[key: string]: any;
};
'utils/proxifyCompat': typeof proxifyCompat;
'utils/classList': (...classes: import("clsx").ClassValue[]) => string;
'utils/extractText': typeof extractText;
'utils/formatNumber': typeof formatNumber;
'utils/mapRoutes': typeof mapRoutes;
'utils/withAttr': (key: string, cb: Function) => (this: Element) => void;
'utils/throttleDebounce': typeof ThrottleDebounce;
'utils/isObject': typeof isObject;
'utils/focusTrap': typeof FocusTrap;
'models/Notification': typeof Notification;
'models/User': typeof User;
'models/Post': typeof Post;
@@ -69,6 +67,7 @@ declare var _default: {
'components/Link': typeof Link;
'components/LinkButton': typeof LinkButton;
'components/Checkbox': typeof Checkbox;
'components/ColorPreviewInput': typeof ColorPreviewInput;
'components/SelectDropdown': typeof SelectDropdown;
'components/ModalManager': typeof ModalManager;
'components/Button': typeof Button;
@@ -93,7 +92,6 @@ declare var _default: {
'states/PaginatedListState': typeof PaginatedListState;
};
export default _default;
import * as extend from "./extend";
import Session from "./Session";
import Store from "./Store";
import BasicEditorDriver from "./utils/BasicEditorDriver";
@@ -118,10 +116,13 @@ import Stream from "./utils/Stream";
import subclassOf from "./utils/subclassOf";
import setRouteWithForcedRefresh from "./utils/setRouteWithForcedRefresh";
import patchMithril from "./utils/patchMithril";
import proxifyCompat from "./utils/proxifyCompat";
import extractText from "./utils/extractText";
import formatNumber from "./utils/formatNumber";
import mapRoutes from "./utils/mapRoutes";
import * as ThrottleDebounce from "./utils/throttleDebounce";
import isObject from "./utils/isObject";
import * as FocusTrap from "./utils/focusTrap";
import Notification from "./models/Notification";
import User from "./models/User";
import Post from "./models/Post";
@@ -148,6 +149,7 @@ import Alert from "./components/Alert";
import Link from "./components/Link";
import LinkButton from "./components/LinkButton";
import Checkbox from "./components/Checkbox";
import ColorPreviewInput from "./components/ColorPreviewInput";
import SelectDropdown from "./components/SelectDropdown";
import ModalManager from "./components/ModalManager";
import Button from "./components/Button";

View File

@@ -15,5 +15,5 @@ export interface AlertAttrs extends ComponentAttrs {
* some controls, and may be dismissible.
*/
export default class Alert<T extends AlertAttrs = AlertAttrs> extends Component<T> {
view(vnode: Mithril.Vnode): JSX.Element;
view(vnode: Mithril.VnodeDOM<T, this>): JSX.Element;
}

View File

@@ -60,8 +60,8 @@ export interface IButtonAttrs extends ComponentAttrs {
* styles can be applied by providing `className="Button"` to the Button component.
*/
export default class Button<CustomAttrs extends IButtonAttrs = IButtonAttrs> extends Component<CustomAttrs> {
view(vnode: Mithril.Vnode<IButtonAttrs, never>): JSX.Element;
oncreate(vnode: Mithril.VnodeDOM<IButtonAttrs, this>): void;
view(vnode: Mithril.VnodeDOM<CustomAttrs, this>): JSX.Element;
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
/**
* Get the template for the button's content.
*/

View File

@@ -15,14 +15,14 @@ export default class Checkbox extends Component<import("../Component").Component
/**
* Get the template for the checkbox's display (tick/cross icon).
*
* @return {*}
* @return {import('mithril').Children}
* @protected
*/
protected getDisplay(): any;
protected getDisplay(): import('mithril').Children;
/**
* Run a callback when the state of the checkbox is changed.
*
* @param {Boolean} checked
* @param {boolean} checked
* @protected
*/
protected onchange(checked: boolean): void;

View File

@@ -0,0 +1,6 @@
import type Mithril from 'mithril';
import Component, { ComponentAttrs } from '../Component';
export default class ColorPreviewInput extends Component {
value?: string;
view(vnode: Mithril.Vnode<ComponentAttrs, this>): JSX.Element;
}

View File

@@ -22,17 +22,17 @@ export default class Dropdown extends Component<import("../Component").Component
/**
* Get the template for the button.
*
* @return {*}
* @return {import('mithril').Children}
* @protected
*/
protected getButton(children: any): any;
protected getButton(children: any): import('mithril').Children;
/**
* Get the template for the button's content.
*
* @return {*}
* @return {import('mithril').Children}
* @protected
*/
protected getButtonContent(children: any): any;
protected getButtonContent(children: any): import('mithril').Children;
getMenu(items: any): JSX.Element;
}
import Component from "../Component";

View File

@@ -1,25 +1,31 @@
/**
* The `EditUserModal` component displays a modal dialog with a login form.
*/
export default class EditUserModal extends Modal {
username: Stream<any> | undefined;
email: Stream<any> | undefined;
isEmailConfirmed: Stream<any> | undefined;
setPassword: Stream<boolean> | undefined;
password: Stream<any> | undefined;
groups: {} | undefined;
fields(): ItemList;
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
import Modal, { IInternalModalAttrs } from './Modal';
import ItemList from '../utils/ItemList';
import Stream from '../utils/Stream';
import type Mithril from 'mithril';
import type User from '../models/User';
import type { SaveAttributes } from '../Model';
export interface IEditUserModalAttrs extends IInternalModalAttrs {
user: User;
}
export default class EditUserModal<CustomAttrs extends IEditUserModalAttrs = IEditUserModalAttrs> extends Modal<CustomAttrs> {
protected username: Stream<string>;
protected email: Stream<string>;
protected isEmailConfirmed: Stream<boolean>;
protected setPassword: Stream<boolean>;
protected password: Stream<string>;
protected groups: Record<string, Stream<boolean>>;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
className(): string;
title(): import("@askvortsov/rich-icu-message-formatter").NestedStringArray;
content(): JSX.Element;
fields(): ItemList<unknown>;
activate(): void;
data(): {
relationships: {};
};
nonAdminEditingAdmin(): any;
data(): SaveAttributes;
onsubmit(e: SubmitEvent): void;
nonAdminEditingAdmin(): boolean | null;
/**
* @internal
* @protected
*/
protected userIsAdmin(user: any): any;
protected userIsAdmin(user: User | null): boolean | null;
}
import Modal from "./Modal";
import Stream from "../utils/Stream";
import ItemList from "../utils/ItemList";

View File

@@ -16,10 +16,10 @@ export default class LinkButton extends Button<import("./Button").IButtonAttrs>
/**
* Determine whether a component with the given attrs is 'active'.
*
* @param {Object} attrs
* @return {Boolean}
* @param {object} attrs
* @return {boolean}
*/
static isActive(attrs: Object): boolean;
static isActive(attrs: object): boolean;
constructor();
}
import Button from "./Button";

View File

@@ -1,67 +1,68 @@
import Component from '../Component';
import { AlertAttrs } from './Alert';
import type Mithril from 'mithril';
import type ModalManagerState from '../states/ModalManagerState';
import type RequestError from '../utils/RequestError';
import type ModalManager from './ModalManager';
export interface IInternalModalAttrs {
state: ModalManagerState;
animateShow: ModalManager['animateShow'];
animateHide: ModalManager['animateHide'];
}
/**
* The `Modal` component displays a modal dialog, wrapped in a form. Subclasses
* should implement the `className`, `title`, and `content` methods.
*
* @abstract
*/
export default class Modal extends Component<import("../Component").ComponentAttrs, undefined> {
export default abstract class Modal<ModalAttrs extends IInternalModalAttrs = IInternalModalAttrs> extends Component<ModalAttrs> {
/**
* Determine whether or not the modal should be dismissible via an 'x' button.
*/
static isDismissible: boolean;
constructor();
static readonly isDismissible: boolean;
protected loading: boolean;
/**
* Attributes for an alert component to show below the header.
*
* @type {object}
*/
alertAttrs: object;
alertAttrs: AlertAttrs | null;
oninit(vnode: Mithril.Vnode<ModalAttrs, this>): void;
oncreate(vnode: Mithril.VnodeDOM<ModalAttrs, this>): void;
onbeforeremove(vnode: Mithril.VnodeDOM<ModalAttrs, this>): Promise<void> | void;
/**
* @todo split into FormModal and Modal in 2.0
*/
view(): JSX.Element;
/**
* Get the class name to apply to the modal.
*
* @return {String}
* @abstract
*/
className(): string;
abstract className(): string;
/**
* Get the title of the modal dialog.
*
* @return {String}
* @abstract
*/
title(): string;
abstract title(): Mithril.Children;
/**
* Get the content of the modal.
*
* @return {VirtualElement}
* @abstract
*/
content(): any;
abstract content(): Mithril.Children;
/**
* Handle the modal form's submit event.
*
* @param {Event} e
*/
onsubmit(): void;
onsubmit(e: SubmitEvent): void;
/**
* Focus on the first input when the modal is ready to be used.
* Callback executed when the modal is shown and ready to be interacted with.
*
* @remark Focuses the first input in the modal.
*/
onready(): void;
/**
* Hide the modal.
* Hides the modal.
*/
hide(): void;
/**
* Stop loading.
* Sets `loading` to false and triggers a redraw.
*/
loaded(): void;
loading: boolean | undefined;
/**
* Show an alert describing an error returned from the API, and give focus to
* the first relevant field.
*
* @param {RequestError} error
* Shows an alert describing an error returned from the API, and gives focus to
* the first relevant field involved in the error.
*/
onerror(error: any): void;
onerror(error: RequestError): void;
}
import Component from "../Component";

View File

@@ -1,11 +1,25 @@
import Component from '../Component';
import { FocusTrap } from '../utils/focusTrap';
import type ModalManagerState from '../states/ModalManagerState';
import type Mithril from 'mithril';
interface IModalManagerAttrs {
state: ModalManagerState;
}
/**
* The `ModalManager` component manages a modal dialog. Only one modal dialog
* can be shown at once; loading a new component into the ModalManager will
* overwrite the previous one.
*/
export default class ModalManager extends Component<import("../Component").ComponentAttrs, undefined> {
constructor();
animateShow(readyCallback: any): void;
export default class ModalManager extends Component<IModalManagerAttrs> {
protected focusTrap: FocusTrap | undefined;
/**
* Whether a modal is currently shown by this modal manager.
*/
protected modalShown: boolean;
view(vnode: Mithril.VnodeDOM<IModalManagerAttrs, this>): Mithril.Children;
oncreate(vnode: Mithril.VnodeDOM<IModalManagerAttrs, this>): void;
onupdate(vnode: Mithril.VnodeDOM<IModalManagerAttrs, this>): void;
animateShow(readyCallback: () => void): void;
animateHide(): void;
}
import Component from "../Component";
export {};

View File

@@ -18,23 +18,23 @@ export default class Navigation extends Component<import("../Component").Compone
/**
* Get the back button.
*
* @return {Object}
* @return {import('mithril').Children}
* @protected
*/
protected getBackButton(): Object;
protected getBackButton(): import('mithril').Children;
/**
* Get the pane pinned toggle button.
*
* @return {Object|String}
* @return {import('mithril').Children}
* @protected
*/
protected getPaneButton(): Object | string;
protected getPaneButton(): import('mithril').Children;
/**
* Get the drawer toggle button.
*
* @return {Object|String}
* @return {import('mithril').Children}
* @protected
*/
protected getDrawerButton(): Object | string;
protected getDrawerButton(): import('mithril').Children;
}
import Component from "../Component";

View File

@@ -1,3 +1,4 @@
import type Mithril from 'mithril';
import Component from '../Component';
export interface IPageAttrs {
key?: number;
@@ -9,7 +10,19 @@ export interface IPageAttrs {
* @abstract
*/
export default abstract class Page<CustomAttrs extends IPageAttrs = IPageAttrs> extends Component<CustomAttrs> {
oninit(vnode: any): void;
oncreate(vnode: any): void;
onremove(vnode: any): void;
/**
* A class name to apply to the body while the route is active.
*/
protected bodyClass: string;
/**
* Whether we should scroll to the top of the page when its rendered.
*/
protected scrollTopOnCreate: boolean;
/**
* Whether the browser should restore scroll state on refreshes.
*/
protected useBrowserScrollRestoration: boolean;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
onremove(vnode: Mithril.VnodeDOM<CustomAttrs, this>): void;
}

View File

@@ -1,3 +1,12 @@
export default class RequestErrorModal extends Modal {
/// <reference types="mithril" />
import type RequestError from '../utils/RequestError';
import Modal, { IInternalModalAttrs } from './Modal';
export interface IRequestErrorModalAttrs extends IInternalModalAttrs {
error: RequestError;
formattedError: string[];
}
export default class RequestErrorModal<CustomAttrs extends IRequestErrorModalAttrs = IRequestErrorModalAttrs> extends Modal<CustomAttrs> {
className(): string;
title(): string;
content(): JSX.Element;
}
import Modal from "./Modal";

View File

@@ -7,9 +7,10 @@ export default class SplitDropdown extends Dropdown {
* Get the first child. If the first child is an array, the first item in that
* array will be returned.
*
* @return {*}
* @param {unknown[] | unknown} children
* @return {unknown}
* @protected
*/
protected getFirstChild(children: any): any;
protected getFirstChild(children: unknown[] | unknown): unknown;
}
import Dropdown from "./Dropdown";

View File

@@ -36,19 +36,19 @@ export default class TextEditor extends Component<import("../Component").Compone
/**
* Build an item list for the text editor controls.
*
* @return {ItemList}
* @return {ItemList<import('mithril').Children>}
*/
controlItems(): ItemList;
controlItems(): ItemList<import('mithril').Children>;
/**
* Build an item list for the toolbar controls.
*
* @return {ItemList}
* @return {ItemList<import('mithril').Children>}
*/
toolbarItems(): ItemList;
toolbarItems(): ItemList<import('mithril').Children>;
/**
* Handle input into the textarea.
*
* @param {String} value
* @param {string} value
*/
oninput(value: string): void;
/**

View File

@@ -19,11 +19,11 @@
* // something that needs to be run on creation and update
* });
*
* @param {object} object The object that owns the method
* @param {string|string[]} methods The name or names of the method(s) to extend
* @param {function} callback A callback which mutates the method's output
* @param object The object that owns the method
* @param methods The name or names of the method(s) to extend
* @param callback A callback which mutates the method's output
*/
export function extend(object: object, methods: string | string[], callback: Function): void;
export declare function extend<T extends Record<string, any>, K extends KeyOfType<T, Function>>(object: T, methods: K | K[], callback: (this: T, val: ReturnType<T[K]>, ...args: Parameters<T[K]>) => void): void;
/**
* Override an object's method by replacing it with a new function, so that the
* new function will be run every time the object's method is called.
@@ -47,8 +47,8 @@ export function extend(object: object, methods: string | string[], callback: Fun
* // something that needs to be run on creation and update
* });
*
* @param {object} object The object that owns the method
* @param {string|string[]} method The name or names of the method(s) to override
* @param {function} newMethod The method to replace it with
* @param object The object that owns the method
* @param methods The name or names of the method(s) to override
* @param newMethod The method to replace it with
*/
export function override(object: object, methods: any, newMethod: Function): void;
export declare function override<T extends Record<any, any>, K extends KeyOfType<T, Function>>(object: T, methods: K | K[], newMethod: (this: T, orig: T[K], ...args: Parameters<T[K]>) => void): void;

View File

@@ -1,5 +1,5 @@
export default class Model {
constructor(type: any, model?: any);
constructor(type: any, model?: null);
type: any;
attributes: any[];
hasOnes: any[];

View File

@@ -1,9 +1,12 @@
import type Mithril from 'mithril';
import type { ComponentAttrs } from '../Component';
import User from '../models/User';
export interface AvatarAttrs extends ComponentAttrs {
}
/**
* The `avatar` helper displays a user's avatar.
*
* @param user
* @param attrs Attributes to apply to the avatar element
*/
export default function avatar(user: User, attrs?: Object): Mithril.Vnode;
export default function avatar(user: User, attrs?: ComponentAttrs): Mithril.Vnode;

View File

@@ -10,3 +10,17 @@
* can fix.
*/
export default function fireDebugWarning(...args: Parameters<typeof console.warn>): void;
/**
* Fire a Flarum deprecation warning which is shown in the JS console.
*
* These warnings are only shown when the forum is in debug mode, and the function exists to
* reduce bundle size caused by multiple warnings across our JavaScript.
*
* @param message The message to display. (Short, but sweet, please!)
* @param githubId The PR or Issue ID with more info in relation to this change.
* @param [removedFrom] The version in which this feature will be completely removed. (default: 2.0)
* @param [repo] The repo which the issue or PR is located in. (default: flarum/core)
*
* @see {@link fireDebugWarning}
*/
export declare function fireDeprecationWarning(message: string, githubId: string, removedFrom?: string, repo?: string): void;

View File

@@ -1,6 +1,34 @@
import type Mithril from 'mithril';
import { ComponentAttrs } from '../Component';
declare type ModdedVnodeAttrs = {
itemClassName?: string;
key?: string;
};
declare type ModdedTag = Mithril.Vnode['tag'] & {
isListItem?: boolean;
isActive?: (attrs: ComponentAttrs) => boolean;
};
declare type ModdedVnode = Mithril.Vnode<ModdedVnodeAttrs> & {
itemName?: string;
itemClassName?: string;
tag: ModdedTag;
};
declare type ModdedChild = ModdedVnode | string | number | boolean | null | undefined;
declare type ModdedChildArray = ModdedChildren[];
declare type ModdedChildren = ModdedChild | ModdedChildArray;
/**
* The `listItems` helper wraps a collection of components in <li> tags,
* stripping out any unnecessary `Separator` components.
* This type represents an element of a list returned by `ItemList.toArray()`,
* coupled with some static properties used on various components.
*/
export default function listItems(items: Mithril.Vnode | Array<Mithril.Vnode>): Array<Mithril.Vnode>;
export declare type ModdedChildrenWithItemName = ModdedChildren & {
itemName?: string;
};
/**
* The `listItems` helper wraps an array of components in the provided tag,
* stripping out any unnecessary `Separator` components.
*
* By default, this tag is an `<li>` tag, but this is customisable through the
* second function parameter, `customTag`.
*/
export default function listItems<Attrs extends ComponentAttrs>(rawItems: ModdedChildrenWithItemName[], customTag?: VnodeElementTag<Attrs>, attributes?: Attrs): Mithril.Vnode[];
export {};

View File

@@ -6,7 +6,7 @@
* punctuateSeries(['Toby', 'Franz', 'Dominion']) // Toby, Franz, and Dominion
* ```
*
* @param {Array} items
* @return {VirtualElement}
* @param {import('mithril').Children[]} items
* @return {import('mithril').Children}')}
*/
export default function punctuateSeries(items: any[]): any;
export default function punctuateSeries(items: import('mithril').Children[]): import('mithril').Children;

View File

@@ -3,4 +3,4 @@ import User from '../models/User';
/**
* The `useronline` helper displays a green circle if the user is online
*/
export default function userOnline(user: User): Mithril.Vnode;
export default function userOnline(user: User): Mithril.Vnode<{}, {}> | null;

View File

@@ -4,4 +4,4 @@ import User from '../models/User';
* The `username` helper displays a user's username in a <span class="username">
* tag. If the user doesn't exist, the username will be displayed as [deleted].
*/
export default function username(user: User): Mithril.Vnode;
export default function username(user: User | null | undefined | false): Mithril.Vnode;

View File

@@ -1,3 +1,13 @@
import * as Extend from "./extend/index";
import app from "./app";
import 'expose-loader?exposes=$,jQuery!jquery';
import 'expose-loader?exposes=m!mithril';
import 'expose-loader?exposes=dayjs!dayjs';
import 'bootstrap/js/affix';
import 'bootstrap/js/dropdown';
import 'bootstrap/js/modal';
import 'bootstrap/js/tooltip';
import 'bootstrap/js/transition';
import 'jquery.hotkeys/jquery.hotkeys';
import * as Extend from './extend/index';
import app from './app';
export { Extend, app };
import './utils/arrayFlatPolyfill';

View File

@@ -1,3 +1,48 @@
import Model from '../Model';
import ItemList from '../utils/ItemList';
import Mithril from 'mithril';
import Post from './Post';
import User from './User';
export default class Discussion extends Model {
title(): string;
slug(): string;
createdAt(): Date | undefined;
user(): false | User | null;
firstPost(): false | Post | null;
lastPostedAt(): Date | null | undefined;
lastPostedUser(): false | User | null;
lastPost(): false | Post | null;
lastPostNumber(): number | null | undefined;
commentCount(): number | undefined;
replyCount(): Number;
posts(): false | (Post | undefined)[];
mostRelevantPost(): false | Post | null;
lastReadAt(): Date | null | undefined;
lastReadPostNumber(): number | null | undefined;
isUnread(): boolean;
isRead(): boolean;
hiddenAt(): Date | null | undefined;
hiddenUser(): false | User | null;
isHidden(): boolean;
canReply(): boolean | undefined;
canRename(): boolean | undefined;
canHide(): boolean | undefined;
canDelete(): boolean | undefined;
/**
* Remove a post from the discussion's posts relationship.
*/
removePost(id: string): void;
/**
* Get the estimated number of unread posts in this discussion for the current
* user.
*/
unreadCount(): number;
/**
* Get the Badge components that apply to this discussion.
*/
badges(): ItemList<Mithril.Children>;
/**
* Get a list of all of the post IDs in this discussion.
*/
postIds(): string[];
}
import Model from "../Model";

View File

@@ -1,3 +1,4 @@
import Model from '../Model';
export default class Forum extends Model {
apiEndpoint(): string;
}
import Model from "../Model";

View File

@@ -1,9 +1,11 @@
export default Group;
declare class Group extends Model {
import Model from '../Model';
export default class Group extends Model {
static ADMINISTRATOR_ID: string;
static GUEST_ID: string;
static MEMBER_ID: string;
nameSingular(): string;
namePlural(): string;
color(): string | null;
icon(): string | null;
isHidden(): boolean;
}
declare namespace Group {
const ADMINISTRATOR_ID: string;
const GUEST_ID: string;
const MEMBER_ID: string;
}
import Model from "../Model";

View File

@@ -1,3 +1,11 @@
import Model from '../Model';
import User from './User';
export default class Notification extends Model {
contentType(): string;
content(): string;
createdAt(): Date;
isRead(): boolean;
user(): false | User;
fromUser(): false | User | null;
subject(): false | Model | null;
}
import Model from "../Model";

View File

@@ -1,3 +1,23 @@
import Model from '../Model';
import Discussion from './Discussion';
import User from './User';
export default class Post extends Model {
number(): number;
discussion(): Discussion;
createdAt(): Date;
user(): false | User;
contentType(): string | null;
content(): string | null | undefined;
contentHtml(): string | null | undefined;
renderFailed(): boolean | undefined;
contentPlain(): string | null | undefined;
editedAt(): Date | null | undefined;
editedUser(): false | User | null;
isEdited(): boolean;
hiddenAt(): Date | null | undefined;
hiddenUser(): false | User | null;
isHidden(): boolean;
canEdit(): boolean | undefined;
canHide(): boolean | undefined;
canDelete(): boolean | undefined;
}
import Model from "../Model";

View File

@@ -1,3 +1,46 @@
import { Color } from 'color-thief-browser';
import Model from '../Model';
import ItemList from '../utils/ItemList';
import Mithril from 'mithril';
import Group from './Group';
export default class User extends Model {
username(): string;
slug(): string;
displayName(): string;
email(): string | undefined;
isEmailConfirmed(): boolean | undefined;
password(): string | undefined;
avatarUrl(): string | null;
preferences(): Record<string, any> | null | undefined;
groups(): false | (Group | undefined)[];
joinTime(): Date | null | undefined;
lastSeenAt(): Date | null | undefined;
markedAllAsReadAt(): Date | null | undefined;
unreadNotificationCount(): number | undefined;
newNotificationCount(): number | undefined;
discussionCount(): number | undefined;
commentCount(): number | undefined;
canEdit(): boolean | undefined;
canEditCredentials(): boolean | undefined;
canEditGroups(): boolean | undefined;
canDelete(): boolean | undefined;
color(): string;
protected avatarColor: Color | null;
/**
* Check whether or not the user has been seen in the last 5 minutes.
*/
isOnline(): boolean;
/**
* Get the Badge components that apply to this user.
*/
badges(): ItemList<Mithril.Children>;
/**
* Calculate the dominant color of the user's avatar. The dominant color will
* be set to the `avatarColor` property once it has been calculated.
*/
protected calculateAvatarColor(): void;
/**
* Update the user's preferences.
*/
savePreferences(newPreferences: Record<string, unknown>): Promise<this>;
}
import Model from "../Model";

View File

@@ -1,21 +1,30 @@
import type Mithril from 'mithril';
import type { RouteResolver } from '../Application';
import type { default as Component, ComponentAttrs } from '../Component';
/**
* Generates a route resolver for a given component.
*
* In addition to regular route resolver functionality:
* - It provide the current route name as an attr
* - It sets a key on the component so a rerender will be triggered on route change.
*/
export default class DefaultResolver {
component: Mithril.Component;
export default class DefaultResolver<Attrs extends ComponentAttrs, Comp extends Component<Attrs & {
routeName: string;
constructor(component: any, routeName: any);
}>, RouteArgs extends Record<string, unknown> = {}> implements RouteResolver<Attrs, Comp, RouteArgs> {
component: new () => Comp;
routeName: string;
constructor(component: new () => Comp, routeName: string);
/**
* When a route change results in a changed key, a full page
* rerender occurs. This method can be overriden in subclasses
* to prevent rerenders on some route changes.
*/
makeKey(): string;
makeAttrs(vnode: any): any;
onmatch(args: any, requestedPath: any, route: any): Mithril.Component<{}, {}>;
render(vnode: any): any[];
makeAttrs(vnode: Mithril.Vnode<Attrs, Comp>): Attrs & {
routeName: string;
};
onmatch(args: RouteArgs, requestedPath: string, route: string): {
new (): Comp;
};
render(vnode: Mithril.Vnode<Attrs, Comp>): Mithril.Children;
}

View File

@@ -20,15 +20,15 @@ export default class AlertManagerState {
/**
* Show an Alert in the alerts area.
*
* @returns The alert's ID, which can be used to dismiss the alert.
* @return The alert's ID, which can be used to dismiss the alert.
*/
show(children: Mithril.Children): AlertIdentifier;
show(attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
show(componentClass: Alert, attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
show(componentClass: typeof Alert, attrs: AlertAttrs, children: Mithril.Children): AlertIdentifier;
/**
* Dismiss an alert.
*/
dismiss(key: AlertIdentifier): void;
dismiss(key: AlertIdentifier | null): void;
/**
* Clear all alerts.
*/

View File

@@ -1,19 +1,58 @@
import type Component from '../Component';
import Modal from '../components/Modal';
/**
* Ideally, `show` would take a higher-kinded generic, ala:
* `show<Attrs, C>(componentClass: C<Attrs>, attrs: Attrs): void`
* Unfortunately, TypeScript does not support this:
* https://github.com/Microsoft/TypeScript/issues/1213
* Therefore, we have to use this ugly, messy workaround.
*/
declare type UnsafeModalClass = ComponentClass<any, Modal> & {
isDismissible: boolean;
component: typeof Component.component;
};
/**
* Class used to manage modal state.
*
* Accessible on the `app` object via `app.modal` property.
*/
export default class ModalManagerState {
modal: {
componentClass: any;
attrs: any;
} | null;
/**
* Show a modal dialog.
*
* @public
* @internal
*/
public show(componentClass: any, attrs: any): void;
modal: null | {
componentClass: UnsafeModalClass;
attrs?: Record<string, unknown>;
key: number;
};
/**
* Close the modal dialog.
*
* @public
* Used to force re-initialization of modals if a modal
* is replaced by another of the same type.
*/
public close(): void;
closeTimeout: number | undefined;
private key;
private closeTimeout?;
/**
* Shows a modal dialog.
*
* If a modal is already open, the existing one will close and the new modal will replace it.
*
* @example <caption>Show a modal</caption>
* app.modal.show(MyCoolModal, { attr: 'value' });
*
* @example <caption>Show a modal from a lifecycle method (`oncreate`, `view`, etc.)</caption>
* // This "hack" is needed due to quirks with nested redraws in Mithril.
* setTimeout(() => app.modal.show(MyCoolModal, { attr: 'value' }), 0);
*/
show(componentClass: UnsafeModalClass, attrs?: Record<string, unknown>): void;
/**
* Closes the currently open dialog, if one is open.
*/
close(): void;
/**
* Checks if a modal is currently open.
*
* @return `true` if a modal dialog is currently open, otherwise `false`.
*/
isModalOpen(): boolean;
}
export {};

View File

@@ -5,12 +5,11 @@ export default class PageState {
/**
* Determine whether the page matches the given class and data.
*
* @param {object} type The page class to check against. Subclasses are
* accepted as well.
* @param {object} data
* @param {object} type The page class to check against. Subclasses are accepted as well.
* @param {Record<string, unknown>} data
* @return {boolean}
*/
matches(type: object, data?: object): boolean;
matches(type: object, data?: Record<string, unknown>): boolean;
get(key: any): any;
set(key: any, value: any): void;
}

View File

@@ -1,4 +1,5 @@
import Model from '../Model';
import { ApiQueryParamsPlural, ApiResponsePlural } from '../Store';
export interface Page<TModel> {
number: number;
items: TModel[];
@@ -10,24 +11,30 @@ export interface PaginationLocation {
startIndex?: number;
endIndex?: number;
}
export default abstract class PaginatedListState<T extends Model> {
export interface PaginatedListParams {
[key: string]: any;
}
export interface PaginatedListRequestParams extends Omit<ApiQueryParamsPlural, 'include'> {
include?: string | string[];
}
export default abstract class PaginatedListState<T extends Model, P extends PaginatedListParams = PaginatedListParams> {
protected location: PaginationLocation;
protected pageSize: number;
protected pages: Page<T>[];
protected params: any;
protected params: P;
protected initialLoading: boolean;
protected loadingPrev: boolean;
protected loadingNext: boolean;
protected constructor(params?: any, page?: number, pageSize?: number);
protected constructor(params?: P, page?: number, pageSize?: number);
abstract get type(): string;
clear(): void;
loadPrev(): Promise<void>;
loadNext(): Promise<void>;
protected parseResults(pg: number, results: T[]): void;
protected parseResults(pg: number, results: ApiResponsePlural<T>): void;
/**
* Load a new page of results.
*/
protected loadPage(page?: number): Promise<T[]>;
protected loadPage(page?: number): Promise<ApiResponsePlural<T>>;
/**
* Get the parameters that should be passed in the API request.
* Do not include page offset unless subclass overrides loadPage.
@@ -35,7 +42,7 @@ export default abstract class PaginatedListState<T extends Model> {
* @abstract
* @see loadPage
*/
protected requestParams(): any;
protected requestParams(): PaginatedListRequestParams;
/**
* Update the `this.params` object, calling `refresh` if they have changed.
* Use `requestParams` for converting `this.params` into API parameters
@@ -44,8 +51,8 @@ export default abstract class PaginatedListState<T extends Model> {
* @param page
* @see requestParams
*/
refreshParams(newParams: any, page: number): any;
refresh(page?: number): any;
refreshParams(newParams: P, page: number): Promise<void>;
refresh(page?: number): Promise<void>;
getPages(): Page<T>[];
getLocation(): PaginationLocation;
isLoading(): boolean;
@@ -70,9 +77,9 @@ export default abstract class PaginatedListState<T extends Model> {
/**
* Stored state parameters.
*/
getParams(): any;
getParams(): P;
protected getNextPageNumber(): number;
protected getPrevPageNumber(): number;
protected paramsChanged(newParams: any): boolean;
protected paramsChanged(newParams: P): boolean;
protected getAllItems(): T[];
}

View File

@@ -3,8 +3,8 @@ import ItemList from './ItemList';
export default class BasicEditorDriver implements EditorDriverInterface {
el: HTMLTextAreaElement;
constructor(dom: HTMLElement, params: EditorDriverParams);
build(dom: HTMLElement, params: EditorDriverParams): void;
keyHandlers(params: EditorDriverParams): ItemList;
protected build(dom: HTMLElement, params: EditorDriverParams): void;
protected keyHandlers(params: EditorDriverParams): ItemList<(e: KeyboardEvent) => void>;
moveCursorTo(position: number): void;
getSelectionRange(): Array<number>;
getLastNChars(n: number): string;

View File

@@ -4,24 +4,45 @@
* footer.
*/
export default class Drawer {
/**
* @type {import('./focusTrap').FocusTrap}
*/
focusTrap: import('./focusTrap').FocusTrap;
/**
* @type {HTMLDivElement}
*/
appElement: HTMLDivElement;
/**
* @internal
* @type {MediaQueryList}
*/
drawerAvailableMediaQuery: MediaQueryList;
/**
* Handler for the `resize` event on `window`.
*
* This is used to close the drawer when the viewport is widened past the `phone` size.
* At this point, the drawer turns into the standard header that we see on desktop, but
* the drawer is still registered as 'open' internally.
*
* This causes issues with the focus trap, resulting in focus becoming trapped within
* the header on desktop viewports.
*
* @internal
*/
resizeHandler: (e: any) => void;
/**
* Check whether or not the drawer is currently open.
*
* @return {Boolean}
* @public
* @return {boolean}
*/
public isOpen(): boolean;
isOpen(): boolean;
/**
* Hide the drawer.
*
* @public
*/
public hide(): void;
hide(): void;
/**
* Show the drawer.
*
* @public
*/
public show(): void;
show(): void;
$backdrop: JQuery<HTMLElement> | undefined;
}

View File

@@ -1,20 +1,31 @@
declare class Item {
content: any;
export interface IItemObject<T> {
content: T;
itemName: string;
priority: number;
key?: number;
constructor(content: any, priority?: number);
}
declare class Item<T> {
content: T;
priority: number;
constructor(content: T, priority: number);
}
/**
* The `ItemList` class collects items and then arranges them into an array
* by priority.
*/
export default class ItemList {
export default class ItemList<T> {
/**
* The items in the list
* The items in the list.
*/
items: {
[key: string]: Item;
};
protected _items: Record<string, Item<T>>;
/**
* A **read-only copy** of items in the list.
*
* We don't allow adding new items to the ItemList via setting new properties,
* nor do we allow modifying existing items directly.
*
* @deprecated Use {@link ItemList.toObject} instead.
*/
get items(): DeepReadonly<Record<string, Item<T>>>;
/**
* Check whether the list is empty.
*/
@@ -26,33 +37,165 @@ export default class ItemList {
/**
* Get the content of an item.
*/
get(key: string): any;
get(key: string): T;
/**
* Get the priority of an item.
*/
getPriority(key: string): number;
/**
* Add an item to the list.
*
* @param key A unique key for the item.
* @param content The item's content.
* @param [priority] The priority of the item. Items with a higher
* priority will be positioned before items with a lower priority.
* @param priority The priority of the item. Items with a higher priority
* will be positioned before items with a lower priority.
*/
add(key: string, content: any, priority?: number): this;
add(key: string, content: T, priority?: number): this;
/**
* Replace an item in the list, only if it is already present.
* Replace an item and/or priority in the list, only if it is already present.
*
* If `content` or `priority` are `null`, these values will not be replaced.
*
* If the provided `key` is not present, nothing will happen.
*
* @deprecated Please use the {@link ItemList.setContent} and {@link ItemList.setPriority}
* methods to replace items and their priorities. This method will be removed in Flarum 2.0.
*
* @param key The key of the item in the list
* @param content The item's new content
* @param priority The item's new priority
*
* @example <caption>Replace priority and not content.</caption>
* items.replace('myItem', null, 10);
*
* @example <caption>Replace content and not priority.</caption>
* items.replace('myItem', <p>My new value.</p>);
*
* @example <caption>Replace content and priority.</caption>
* items.replace('myItem', <p>My new value.</p>, 10);
*/
replace(key: string, content?: any, priority?: number): this;
replace(key: string, content?: T | null, priority?: number | null): this;
/**
* Replaces an item's content, if the provided item key exists.
*
* If the provided `key` is not present, nothing will happen.
*
* @param key The key of the item in the list
* @param content The item's new content
*
* @example <caption>Replace item content.</caption>
* items.setContent('myItem', <p>My new value.</p>);
*
* @example <caption>Replace item content and priority.</caption>
* items
* .setContent('myItem', <p>My new value.</p>)
* .setPriority('myItem', 10);
*
* @throws If the provided `key` is not present in the ItemList.
*/
setContent(key: string, content: T): this;
/**
* Replaces an item's priority, if the provided item key exists.
*
* If the provided `key` is not present, nothing will happen.
*
* @param key The key of the item in the list
* @param priority The item's new priority
*
* @example <caption>Replace item priority.</caption>
* items.setPriority('myItem', 10);
*
* @example <caption>Replace item priority and content.</caption>
* items
* .setPriority('myItem', 10)
* .setContent('myItem', <p>My new value.</p>);
*
* @throws If the provided `key` is not present in the ItemList.
*/
setPriority(key: string, priority: number): this;
/**
* Remove an item from the list.
*/
remove(key: string): this;
/**
* Merge another list's items into this one.
*
* The list passed to this function will overwrite items which already exist
* with the same key.
*/
merge(items: this): this;
merge(otherList: ItemList<T>): ItemList<T>;
/**
* Convert the list into an array of item content arranged by priority. Each
* item's content will be assigned an `itemName` property equal to the item's
* unique key.
* Convert the list into an array of item content arranged by priority.
*
* This **does not** preserve the original types of primitives and proxies
* all content values to make `itemName` accessible on them.
*
* **NOTE:** If your ItemList holds primitive types (such as numbers, booleans
* or strings), these will be converted to their object counterparts if you do
* not provide `true` to this function.
*
* **NOTE:** Modifying any objects in the final array may also update the
* content of the original ItemList.
*
* @param keepPrimitives Converts item content to objects and sets the
* `itemName` property on them.
*
* @see https://github.com/flarum/core/issues/3030
*/
toArray(): any[];
toArray(keepPrimitives?: false): (T & {
itemName: string;
})[];
/**
* Convert the list into an array of item content arranged by priority.
*
* Content values that are already objects will be proxied and have
* `itemName` accessible on them. Primitive values will not have the
* `itemName` property accessible.
*
* **NOTE:** Modifying any objects in the final array may also update the
* content of the original ItemList.
*
* @param keepPrimitives Converts item content to objects and sets the
* `itemName` property on them.
*/
toArray(keepPrimitives: true): (T extends object ? T & Readonly<{
itemName: string;
}> : T)[];
/**
* A read-only map of all keys to their respective items in no particular order.
*
* We don't allow adding new items to the ItemList via setting new properties,
* nor do we allow modifying existing items directly. You should use the
* {@link ItemList.add}, {@link ItemList.setContent} and
* {@link ItemList.setPriority} methods instead.
*
* To match the old behaviour of the `ItemList.items` property, call
* `Object.values(ItemList.toObject())`.
*
* @example
* const items = new ItemList();
* items.add('b', 'My cool value', 20);
* items.add('a', 'My value', 10);
* items.toObject();
* // {
* // a: { content: 'My value', priority: 10, itemName: 'a' },
* // b: { content: 'My cool value', priority: 20, itemName: 'b' },
* // }
*/
toObject(): DeepReadonly<Record<string, IItemObject<T>>>;
/**
* Proxies an item's content, adding the `itemName` readonly property to it.
*
* @example
* createItemContentProxy({ foo: 'bar' }, 'myItem');
* // { foo: 'bar', itemName: 'myItem' }
*
* @param content The item's content (objects only)
* @param key The item's key
* @return Proxied content
*
* @internal
*/
private createItemContentProxy;
}
export {};

View File

@@ -1,9 +1,21 @@
export default class RequestError {
status: string;
options: object;
import type Mithril from 'mithril';
import type { AlertAttrs } from '../components/Alert';
export declare type InternalFlarumRequestOptions<ResponseType> = Mithril.RequestOptions<ResponseType> & {
url: string;
};
export default class RequestError<ResponseType = string> {
status: number;
options: InternalFlarumRequestOptions<ResponseType>;
xhr: XMLHttpRequest;
responseText: string | null;
response: object | null;
alert: any;
constructor(status: string, responseText: string | null, options: object, xhr: XMLHttpRequest);
response: {
[key: string]: unknown;
errors?: {
detail?: string;
code?: string;
[key: string]: unknown;
}[];
} | null;
alert: AlertAttrs | null;
constructor(status: number, responseText: string | null, options: InternalFlarumRequestOptions<ResponseType>, xhr: XMLHttpRequest);
}

View File

@@ -4,12 +4,11 @@
*/
export default class ScrollListener {
/**
* @param {Function} callback The callback to run when the scroll position
* @param {(top: number) => void} callback The callback to run when the scroll position
* changes.
* @public
*/
constructor(callback: Function);
callback: Function;
constructor(callback: (top: number) => void);
callback: (top: number) => void;
ticking: boolean;
/**
* On each animation frame, as long as the listener is active, run the
@@ -20,21 +19,15 @@ export default class ScrollListener {
protected loop(): void;
/**
* Run the callback, whether there was a scroll event or not.
*
* @public
*/
public update(): void;
update(): void;
/**
* Start listening to and handling the window's scroll position.
*
* @public
*/
public start(): void;
start(): void;
active: (() => void) | null | undefined;
/**
* Stop listening to and handling the window's scroll position.
*
* @public
*/
public stop(): void;
stop(): void;
}

View File

@@ -22,31 +22,23 @@
* @see https://mithril.js.org/lifecycle-methods.html#onbeforeupdate
*/
export default class SubtreeRetainer {
protected callbacks: (() => any)[];
protected data: Record<string, any>;
/**
* @param {...callbacks} callbacks Functions returning data to keep track of.
* @param callbacks Functions returning data to keep track of.
*/
constructor(...callbacks: any[]);
callbacks: any[];
data: {};
constructor(...callbacks: (() => any)[]);
/**
* Return whether any data has changed since the last check.
* If so, Mithril needs to re-diff the vnode and its children.
*
* @return {boolean}
* @public
*/
public needsRebuild(): boolean;
needsRebuild(): boolean;
/**
* Add another callback to be checked.
*
* @param {...Function} callbacks
* @public
*/
public check(...callbacks: Function[]): void;
check(...callbacks: (() => any)[]): void;
/**
* Invalidate the subtree, forcing it to be rerendered.
*
* @public
* Invalidate the subtree, forcing it to be redrawn.
*/
public invalidate(): void;
invalidate(): void;
}

View File

@@ -8,7 +8,7 @@
* position can be anchor to an element that is in or below the viewport, so
* the content in the viewport will stay the same.
*
* @param {DOMElement} element The element to anchor the scroll position to.
* @param {Function} callback The callback to run that will change page content.
* @param {HTMLElement | SVGElement | Element} element The element to anchor the scroll position to.
* @param {() => void} callback The callback to run that will change page content.
*/
export default function anchorScroll(element: any, callback: Function): void;
export default function anchorScroll(element: HTMLElement | SVGElement | Element, callback: () => void): void;

View File

@@ -1,10 +1,10 @@
import Model from '../Model';
/**
* The `computed` utility creates a function that will cache its output until
* any of the dependent values are dirty.
*
* @param {...String} dependentKeys The keys of the dependent values.
* @param {function} compute The function which computes the value using the
* @param dependentKeys The keys of the dependent values.
* @param compute The function which computes the value using the
* dependent values.
* @return {Function}
*/
export default function computed(...dependentKeys: string[]): Function;
export default function computed<T, M = Model>(...args: [...string[], (this: M, ...args: unknown[]) => T]): () => T;

View File

@@ -1,79 +1,97 @@
declare namespace _default {
const handlers: Object;
const handlers: Record<string, unknown>;
/**
* Get all of the registered handlers for an event.
*
* @param {String} event The name of the event.
* @return {Array}
* @param {string} event The name of the event.
* @return {Function[]}
* @protected
*
* @deprecated
*/
function getHandlers(event: string): any[];
function getHandlers(event: string): Function[];
/**
* Get all of the registered handlers for an event.
*
* @param {String} event The name of the event.
* @return {Array}
* @param {string} event The name of the event.
* @return {Function[]}
* @protected
*
* @deprecated
*/
function getHandlers(event: string): any[];
function getHandlers(event: string): Function[];
/**
* Trigger an event.
*
* @param {String} event The name of the event.
* @param {...*} args Arguments to pass to event handlers.
* @public
* @param {string} event The name of the event.
* @param {any[]} args Arguments to pass to event handlers.
*
* @deprecated
*/
function trigger(event: string, ...args: any[]): void;
/**
* Trigger an event.
*
* @param {String} event The name of the event.
* @param {...*} args Arguments to pass to event handlers.
* @public
* @param {string} event The name of the event.
* @param {any[]} args Arguments to pass to event handlers.
*
* @deprecated
*/
function trigger(event: string, ...args: any[]): void;
/**
* Register an event handler.
*
* @param {String} event The name of the event.
* @param {function} handler The function to handle the event.
* @param {string} event The name of the event.
* @param {Function} handler The function to handle the event.
*
* @deprecated
*/
function on(event: string, handler: Function): void;
/**
* Register an event handler.
*
* @param {String} event The name of the event.
* @param {function} handler The function to handle the event.
* @param {string} event The name of the event.
* @param {Function} handler The function to handle the event.
*
* @deprecated
*/
function on(event: string, handler: Function): void;
/**
* Register an event handler so that it will run only once, and then
* unregister itself.
*
* @param {String} event The name of the event.
* @param {function} handler The function to handle the event.
* @param {string} event The name of the event.
* @param {Function} handler The function to handle the event.
*
* @deprecated
*/
function one(event: string, handler: Function): void;
/**
* Register an event handler so that it will run only once, and then
* unregister itself.
*
* @param {String} event The name of the event.
* @param {function} handler The function to handle the event.
* @param {string} event The name of the event.
* @param {Function} handler The function to handle the event.
*
* @deprecated
*/
function one(event: string, handler: Function): void;
/**
* Unregister an event handler.
*
* @param {String} event The name of the event.
* @param {function} handler The function that handles the event.
* @param {string} event The name of the event.
* @param {Function} handler The function that handles the event.
*
* @deprecated
*/
function off(event: string, handler: Function): void;
/**
* Unregister an event handler.
*
* @param {String} event The name of the event.
* @param {function} handler The function that handles the event.
* @param {string} event The name of the event.
* @param {Function} handler The function that handles the event.
*
* @deprecated
*/
function off(event: string, handler: Function): void;
}

View File

@@ -1,7 +1,5 @@
import type Mithril from 'mithril';
/**
* Extract the text nodes from a virtual element.
*
* @param {VirtualElement} vdom
* @return {String}
*/
export default function extractText(vdom: any): string;
export default function extractText(vdom: Mithril.Children): string;

View File

@@ -0,0 +1,20 @@
import { createFocusTrap as _createFocusTrap } from 'focus-trap';
/**
* Creates a focus trap for the given element with the given options.
*
* This function applies some default options that are different to the library.
* Your own options still override these custom defaults:
*
* ```json
* {
escapeDeactivates: false,
* }
* ```
*
* @param element The element to be the focus trap, or a selector that will be used to find the element.
*
* @see https://github.com/focus-trap/focus-trap#readme - Library documentation
*/
declare function createFocusTrap(...args: Parameters<typeof _createFocusTrap>): ReturnType<typeof _createFocusTrap>;
export * from 'focus-trap';
export { createFocusTrap };

View File

@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
/**
* The `humanTime` utility converts a date to a localized, human-readable time-
* ago string.
*/
export default function humanTime(time: Date): string;
export default function humanTime(time: dayjs.ConfigType): string;

View File

@@ -0,0 +1,24 @@
/**
* Returns if the passed value is an object.
*
* In this context, "object" refers to **any non-primitive value**, including
* arrays, function, maps, dates, and more.
*
* @example
* isObject({}); // true
* @example
* isObject([]); // true
* @example
* isObject(function () {}); // true
* @example
* isObject(Object(1)); // true
* @example
* isObject(null); // false
* @example
* isObject(1); // false
* @example
* isObject("hello world"); // false
*
* @see https://github.com/jashkenas/underscore/blob/943977e34e2279503528a71ddcc2dd5f96483945/underscore.js#L87-L91
*/
export default function isObject(obj: unknown): obj is object;

View File

@@ -1,11 +1,13 @@
import type { FlarumGenericRoute, RouteResolver } from '../Application';
import type Component from '../Component';
/**
* The `mapRoutes` utility converts a map of named application routes into a
* format that can be understood by Mithril, and wraps them in route resolvers
* to provide each route with the current route name.
*
* @see https://mithril.js.org/route.html#signature
* @param {Object} routes
* @param {String} [basePath]
* @return {Object}
*/
export default function mapRoutes(routes: Object, basePath?: string | undefined): Object;
export default function mapRoutes(routes: Record<string, FlarumGenericRoute>, basePath?: string): Record<string, RouteResolver<Record<string, unknown>, Component<{
[key: string]: unknown;
routeName: string;
}, undefined>, Record<string, unknown>>>;

View File

@@ -5,8 +5,8 @@
* @example
* class MyClass extends mixin(ExistingClass, evented, etc) {}
*
* @param {Class} Parent The class to extend the new class from.
* @param {...Object} mixins The objects to mix in.
* @return {Class} A new class that extends Parent and contains the mixins.
* @param {object} Parent The class to extend the new class from.
* @param {Record<string, any>[]} mixins The objects to mix in.
* @return {object} A new class that extends Parent and contains the mixins.
*/
export default function mixin(Parent: any, ...mixins: Object[]): any;
export default function mixin(Parent: object, ...mixins: Record<string, any>[]): object;

Some files were not shown because too many files have changed in this diff Show More