Compare commits

..

1 Commits

Author SHA1 Message Date
Teffen Ellis
117bf97eaa web: Flesh out Playwright. 2025-08-01 17:49:12 +02:00
85 changed files with 1110 additions and 2234 deletions

View File

@@ -42,7 +42,7 @@ class TestBindingsAPI(APITestCase):
)
def test_invalid_too_little(self):
"""Test invalid binding (too little)"""
"""Test invvalid binding (too little)"""
response = self.client.post(
reverse("authentik_api:policybinding-list"),
data={"target": self.pbm.pk, "order": 0},

98
uv.lock generated
View File

@@ -19,7 +19,7 @@ wheels = [
[[package]]
name = "aiohttp"
version = "3.12.15"
version = "3.12.14"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "aiohappyeyeballs" },
@@ -30,25 +30,25 @@ dependencies = [
{ name = "propcache" },
{ name = "yarl" },
]
sdist = { url = "https://files.pythonhosted.org/packages/9b/e7/d92a237d8802ca88483906c388f7c201bbe96cd80a165ffd0ac2f6a8d59f/aiohttp-3.12.15.tar.gz", hash = "sha256:4fc61385e9c98d72fcdf47e6dd81833f47b2f77c114c29cd64a361be57a763a2", size = 7823716, upload-time = "2025-07-29T05:52:32.215Z" }
sdist = { url = "https://files.pythonhosted.org/packages/e6/0b/e39ad954107ebf213a2325038a3e7a506be3d98e1435e1f82086eec4cde2/aiohttp-3.12.14.tar.gz", hash = "sha256:6e06e120e34d93100de448fd941522e11dafa78ef1a893c179901b7d66aa29f2", size = 7822921, upload-time = "2025-07-10T13:05:33.968Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/f2/33/918091abcf102e39d15aba2476ad9e7bd35ddb190dcdd43a854000d3da0d/aiohttp-3.12.15-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:9f922ffd05034d439dde1c77a20461cf4a1b0831e6caa26151fe7aa8aaebc315", size = 696741, upload-time = "2025-07-29T05:51:19.021Z" },
{ url = "https://files.pythonhosted.org/packages/b5/2a/7495a81e39a998e400f3ecdd44a62107254803d1681d9189be5c2e4530cd/aiohttp-3.12.15-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2ee8a8ac39ce45f3e55663891d4b1d15598c157b4d494a4613e704c8b43112cd", size = 474407, upload-time = "2025-07-29T05:51:21.165Z" },
{ url = "https://files.pythonhosted.org/packages/49/fc/a9576ab4be2dcbd0f73ee8675d16c707cfc12d5ee80ccf4015ba543480c9/aiohttp-3.12.15-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3eae49032c29d356b94eee45a3f39fdf4b0814b397638c2f718e96cfadf4c4e4", size = 466703, upload-time = "2025-07-29T05:51:22.948Z" },
{ url = "https://files.pythonhosted.org/packages/09/2f/d4bcc8448cf536b2b54eed48f19682031ad182faa3a3fee54ebe5b156387/aiohttp-3.12.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b97752ff12cc12f46a9b20327104448042fce5c33a624f88c18f66f9368091c7", size = 1705532, upload-time = "2025-07-29T05:51:25.211Z" },
{ url = "https://files.pythonhosted.org/packages/f1/f3/59406396083f8b489261e3c011aa8aee9df360a96ac8fa5c2e7e1b8f0466/aiohttp-3.12.15-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:894261472691d6fe76ebb7fcf2e5870a2ac284c7406ddc95823c8598a1390f0d", size = 1686794, upload-time = "2025-07-29T05:51:27.145Z" },
{ url = "https://files.pythonhosted.org/packages/dc/71/164d194993a8d114ee5656c3b7ae9c12ceee7040d076bf7b32fb98a8c5c6/aiohttp-3.12.15-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5fa5d9eb82ce98959fc1031c28198b431b4d9396894f385cb63f1e2f3f20ca6b", size = 1738865, upload-time = "2025-07-29T05:51:29.366Z" },
{ url = "https://files.pythonhosted.org/packages/1c/00/d198461b699188a93ead39cb458554d9f0f69879b95078dce416d3209b54/aiohttp-3.12.15-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f0fa751efb11a541f57db59c1dd821bec09031e01452b2b6217319b3a1f34f3d", size = 1788238, upload-time = "2025-07-29T05:51:31.285Z" },
{ url = "https://files.pythonhosted.org/packages/85/b8/9e7175e1fa0ac8e56baa83bf3c214823ce250d0028955dfb23f43d5e61fd/aiohttp-3.12.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5346b93e62ab51ee2a9d68e8f73c7cf96ffb73568a23e683f931e52450e4148d", size = 1710566, upload-time = "2025-07-29T05:51:33.219Z" },
{ url = "https://files.pythonhosted.org/packages/59/e4/16a8eac9df39b48ae102ec030fa9f726d3570732e46ba0c592aeeb507b93/aiohttp-3.12.15-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:049ec0360f939cd164ecbfd2873eaa432613d5e77d6b04535e3d1fbae5a9e645", size = 1624270, upload-time = "2025-07-29T05:51:35.195Z" },
{ url = "https://files.pythonhosted.org/packages/1f/f8/cd84dee7b6ace0740908fd0af170f9fab50c2a41ccbc3806aabcb1050141/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:b52dcf013b57464b6d1e51b627adfd69a8053e84b7103a7cd49c030f9ca44461", size = 1677294, upload-time = "2025-07-29T05:51:37.215Z" },
{ url = "https://files.pythonhosted.org/packages/ce/42/d0f1f85e50d401eccd12bf85c46ba84f947a84839c8a1c2c5f6e8ab1eb50/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:9b2af240143dd2765e0fb661fd0361a1b469cab235039ea57663cda087250ea9", size = 1708958, upload-time = "2025-07-29T05:51:39.328Z" },
{ url = "https://files.pythonhosted.org/packages/d5/6b/f6fa6c5790fb602538483aa5a1b86fcbad66244997e5230d88f9412ef24c/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ac77f709a2cde2cc71257ab2d8c74dd157c67a0558a0d2799d5d571b4c63d44d", size = 1651553, upload-time = "2025-07-29T05:51:41.356Z" },
{ url = "https://files.pythonhosted.org/packages/04/36/a6d36ad545fa12e61d11d1932eef273928b0495e6a576eb2af04297fdd3c/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:47f6b962246f0a774fbd3b6b7be25d59b06fdb2f164cf2513097998fc6a29693", size = 1727688, upload-time = "2025-07-29T05:51:43.452Z" },
{ url = "https://files.pythonhosted.org/packages/aa/c8/f195e5e06608a97a4e52c5d41c7927301bf757a8e8bb5bbf8cef6c314961/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:760fb7db442f284996e39cf9915a94492e1896baac44f06ae551974907922b64", size = 1761157, upload-time = "2025-07-29T05:51:45.643Z" },
{ url = "https://files.pythonhosted.org/packages/05/6a/ea199e61b67f25ba688d3ce93f63b49b0a4e3b3d380f03971b4646412fc6/aiohttp-3.12.15-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:ad702e57dc385cae679c39d318def49aef754455f237499d5b99bea4ef582e51", size = 1710050, upload-time = "2025-07-29T05:51:48.203Z" },
{ url = "https://files.pythonhosted.org/packages/b4/2e/ffeb7f6256b33635c29dbed29a22a723ff2dd7401fff42ea60cf2060abfb/aiohttp-3.12.15-cp313-cp313-win32.whl", hash = "sha256:f813c3e9032331024de2eb2e32a88d86afb69291fbc37a3a3ae81cc9917fb3d0", size = 422647, upload-time = "2025-07-29T05:51:50.718Z" },
{ url = "https://files.pythonhosted.org/packages/1b/8e/78ee35774201f38d5e1ba079c9958f7629b1fd079459aea9467441dbfbf5/aiohttp-3.12.15-cp313-cp313-win_amd64.whl", hash = "sha256:1a649001580bdb37c6fdb1bebbd7e3bc688e8ec2b5c6f52edbb664662b17dc84", size = 449067, upload-time = "2025-07-29T05:51:52.549Z" },
{ url = "https://files.pythonhosted.org/packages/06/48/e0d2fa8ac778008071e7b79b93ab31ef14ab88804d7ba71b5c964a7c844e/aiohttp-3.12.14-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:3143a7893d94dc82bc409f7308bc10d60285a3cd831a68faf1aa0836c5c3c767", size = 695471, upload-time = "2025-07-10T13:04:20.124Z" },
{ url = "https://files.pythonhosted.org/packages/8d/e7/f73206afa33100804f790b71092888f47df65fd9a4cd0e6800d7c6826441/aiohttp-3.12.14-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:3d62ac3d506cef54b355bd34c2a7c230eb693880001dfcda0bf88b38f5d7af7e", size = 473128, upload-time = "2025-07-10T13:04:21.928Z" },
{ url = "https://files.pythonhosted.org/packages/df/e2/4dd00180be551a6e7ee979c20fc7c32727f4889ee3fd5b0586e0d47f30e1/aiohttp-3.12.14-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:48e43e075c6a438937c4de48ec30fa8ad8e6dfef122a038847456bfe7b947b63", size = 465426, upload-time = "2025-07-10T13:04:24.071Z" },
{ url = "https://files.pythonhosted.org/packages/de/dd/525ed198a0bb674a323e93e4d928443a680860802c44fa7922d39436b48b/aiohttp-3.12.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:077b4488411a9724cecc436cbc8c133e0d61e694995b8de51aaf351c7578949d", size = 1704252, upload-time = "2025-07-10T13:04:26.049Z" },
{ url = "https://files.pythonhosted.org/packages/d8/b1/01e542aed560a968f692ab4fc4323286e8bc4daae83348cd63588e4f33e3/aiohttp-3.12.14-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:d8c35632575653f297dcbc9546305b2c1133391089ab925a6a3706dfa775ccab", size = 1685514, upload-time = "2025-07-10T13:04:28.186Z" },
{ url = "https://files.pythonhosted.org/packages/b3/06/93669694dc5fdabdc01338791e70452d60ce21ea0946a878715688d5a191/aiohttp-3.12.14-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6b8ce87963f0035c6834b28f061df90cf525ff7c9b6283a8ac23acee6502afd4", size = 1737586, upload-time = "2025-07-10T13:04:30.195Z" },
{ url = "https://files.pythonhosted.org/packages/a5/3a/18991048ffc1407ca51efb49ba8bcc1645961f97f563a6c480cdf0286310/aiohttp-3.12.14-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f0a2cf66e32a2563bb0766eb24eae7e9a269ac0dc48db0aae90b575dc9583026", size = 1786958, upload-time = "2025-07-10T13:04:32.482Z" },
{ url = "https://files.pythonhosted.org/packages/30/a8/81e237f89a32029f9b4a805af6dffc378f8459c7b9942712c809ff9e76e5/aiohttp-3.12.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdea089caf6d5cde975084a884c72d901e36ef9c2fd972c9f51efbbc64e96fbd", size = 1709287, upload-time = "2025-07-10T13:04:34.493Z" },
{ url = "https://files.pythonhosted.org/packages/8c/e3/bd67a11b0fe7fc12c6030473afd9e44223d456f500f7cf526dbaa259ae46/aiohttp-3.12.14-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8a7865f27db67d49e81d463da64a59365ebd6b826e0e4847aa111056dcb9dc88", size = 1622990, upload-time = "2025-07-10T13:04:36.433Z" },
{ url = "https://files.pythonhosted.org/packages/83/ba/e0cc8e0f0d9ce0904e3cf2d6fa41904e379e718a013c721b781d53dcbcca/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0ab5b38a6a39781d77713ad930cb5e7feea6f253de656a5f9f281a8f5931b086", size = 1676015, upload-time = "2025-07-10T13:04:38.958Z" },
{ url = "https://files.pythonhosted.org/packages/d8/b3/1e6c960520bda094c48b56de29a3d978254637ace7168dd97ddc273d0d6c/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:9b3b15acee5c17e8848d90a4ebc27853f37077ba6aec4d8cb4dbbea56d156933", size = 1707678, upload-time = "2025-07-10T13:04:41.275Z" },
{ url = "https://files.pythonhosted.org/packages/0a/19/929a3eb8c35b7f9f076a462eaa9830b32c7f27d3395397665caa5e975614/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:e4c972b0bdaac167c1e53e16a16101b17c6d0ed7eac178e653a07b9f7fad7151", size = 1650274, upload-time = "2025-07-10T13:04:43.483Z" },
{ url = "https://files.pythonhosted.org/packages/22/e5/81682a6f20dd1b18ce3d747de8eba11cbef9b270f567426ff7880b096b48/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:7442488b0039257a3bdbc55f7209587911f143fca11df9869578db6c26feeeb8", size = 1726408, upload-time = "2025-07-10T13:04:45.577Z" },
{ url = "https://files.pythonhosted.org/packages/8c/17/884938dffaa4048302985483f77dfce5ac18339aad9b04ad4aaa5e32b028/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:f68d3067eecb64c5e9bab4a26aa11bd676f4c70eea9ef6536b0a4e490639add3", size = 1759879, upload-time = "2025-07-10T13:04:47.663Z" },
{ url = "https://files.pythonhosted.org/packages/95/78/53b081980f50b5cf874359bde707a6eacd6c4be3f5f5c93937e48c9d0025/aiohttp-3.12.14-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f88d3704c8b3d598a08ad17d06006cb1ca52a1182291f04979e305c8be6c9758", size = 1708770, upload-time = "2025-07-10T13:04:49.944Z" },
{ url = "https://files.pythonhosted.org/packages/ed/91/228eeddb008ecbe3ffa6c77b440597fdf640307162f0c6488e72c5a2d112/aiohttp-3.12.14-cp313-cp313-win32.whl", hash = "sha256:a3c99ab19c7bf375c4ae3debd91ca5d394b98b6089a03231d4c580ef3c2ae4c5", size = 421688, upload-time = "2025-07-10T13:04:51.993Z" },
{ url = "https://files.pythonhosted.org/packages/66/5f/8427618903343402fdafe2850738f735fd1d9409d2a8f9bcaae5e630d3ba/aiohttp-3.12.14-cp313-cp313-win_amd64.whl", hash = "sha256:3f8aad695e12edc9d571f878c62bedc91adf30c760c8632f09663e5f564f4baa", size = 448098, upload-time = "2025-07-10T13:04:53.999Z" },
]
[[package]]
@@ -111,23 +111,23 @@ wheels = [
[[package]]
name = "argon2-cffi-bindings"
version = "25.1.0"
version = "21.2.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "cffi" },
]
sdist = { url = "https://files.pythonhosted.org/packages/5c/2d/db8af0df73c1cf454f71b2bbe5e356b8c1f8041c979f505b3d3186e520a9/argon2_cffi_bindings-25.1.0.tar.gz", hash = "sha256:b957f3e6ea4d55d820e40ff76f450952807013d361a65d7f28acc0acbf29229d", size = 1783441, upload-time = "2025-07-30T10:02:05.147Z" }
sdist = { url = "https://files.pythonhosted.org/packages/b9/e9/184b8ccce6683b0aa2fbb7ba5683ea4b9c5763f1356347f1312c32e3c66e/argon2-cffi-bindings-21.2.0.tar.gz", hash = "sha256:bb89ceffa6c791807d1305ceb77dbfacc5aa499891d2c55661c6459651fc39e3", size = 1779911, upload-time = "2021-12-01T08:52:55.68Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/1d/57/96b8b9f93166147826da5f90376e784a10582dd39a393c99bb62cfcf52f0/argon2_cffi_bindings-25.1.0-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:aecba1723ae35330a008418a91ea6cfcedf6d31e5fbaa056a166462ff066d500", size = 54121, upload-time = "2025-07-30T10:01:50.815Z" },
{ url = "https://files.pythonhosted.org/packages/0a/08/a9bebdb2e0e602dde230bdde8021b29f71f7841bd54801bcfd514acb5dcf/argon2_cffi_bindings-25.1.0-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:2630b6240b495dfab90aebe159ff784d08ea999aa4b0d17efa734055a07d2f44", size = 29177, upload-time = "2025-07-30T10:01:51.681Z" },
{ url = "https://files.pythonhosted.org/packages/b6/02/d297943bcacf05e4f2a94ab6f462831dc20158614e5d067c35d4e63b9acb/argon2_cffi_bindings-25.1.0-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:7aef0c91e2c0fbca6fc68e7555aa60ef7008a739cbe045541e438373bc54d2b0", size = 31090, upload-time = "2025-07-30T10:01:53.184Z" },
{ url = "https://files.pythonhosted.org/packages/c1/93/44365f3d75053e53893ec6d733e4a5e3147502663554b4d864587c7828a7/argon2_cffi_bindings-25.1.0-cp39-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1e021e87faa76ae0d413b619fe2b65ab9a037f24c60a1e6cc43457ae20de6dc6", size = 81246, upload-time = "2025-07-30T10:01:54.145Z" },
{ url = "https://files.pythonhosted.org/packages/09/52/94108adfdd6e2ddf58be64f959a0b9c7d4ef2fa71086c38356d22dc501ea/argon2_cffi_bindings-25.1.0-cp39-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d3e924cfc503018a714f94a49a149fdc0b644eaead5d1f089330399134fa028a", size = 87126, upload-time = "2025-07-30T10:01:55.074Z" },
{ url = "https://files.pythonhosted.org/packages/72/70/7a2993a12b0ffa2a9271259b79cc616e2389ed1a4d93842fac5a1f923ffd/argon2_cffi_bindings-25.1.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:c87b72589133f0346a1cb8d5ecca4b933e3c9b64656c9d175270a000e73b288d", size = 80343, upload-time = "2025-07-30T10:01:56.007Z" },
{ url = "https://files.pythonhosted.org/packages/78/9a/4e5157d893ffc712b74dbd868c7f62365618266982b64accab26bab01edc/argon2_cffi_bindings-25.1.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:1db89609c06afa1a214a69a462ea741cf735b29a57530478c06eb81dd403de99", size = 86777, upload-time = "2025-07-30T10:01:56.943Z" },
{ url = "https://files.pythonhosted.org/packages/74/cd/15777dfde1c29d96de7f18edf4cc94c385646852e7c7b0320aa91ccca583/argon2_cffi_bindings-25.1.0-cp39-abi3-win32.whl", hash = "sha256:473bcb5f82924b1becbb637b63303ec8d10e84c8d241119419897a26116515d2", size = 27180, upload-time = "2025-07-30T10:01:57.759Z" },
{ url = "https://files.pythonhosted.org/packages/e2/c6/a759ece8f1829d1f162261226fbfd2c6832b3ff7657384045286d2afa384/argon2_cffi_bindings-25.1.0-cp39-abi3-win_amd64.whl", hash = "sha256:a98cd7d17e9f7ce244c0803cad3c23a7d379c301ba618a5fa76a67d116618b98", size = 31715, upload-time = "2025-07-30T10:01:58.56Z" },
{ url = "https://files.pythonhosted.org/packages/42/b9/f8d6fa329ab25128b7e98fd83a3cb34d9db5b059a9847eddb840a0af45dd/argon2_cffi_bindings-25.1.0-cp39-abi3-win_arm64.whl", hash = "sha256:b0fdbcf513833809c882823f98dc2f931cf659d9a1429616ac3adebb49f5db94", size = 27149, upload-time = "2025-07-30T10:01:59.329Z" },
{ url = "https://files.pythonhosted.org/packages/d4/13/838ce2620025e9666aa8f686431f67a29052241692a3dd1ae9d3692a89d3/argon2_cffi_bindings-21.2.0-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:ccb949252cb2ab3a08c02024acb77cfb179492d5701c7cbdbfd776124d4d2367", size = 29658, upload-time = "2021-12-01T09:09:17.016Z" },
{ url = "https://files.pythonhosted.org/packages/b3/02/f7f7bb6b6af6031edb11037639c697b912e1dea2db94d436e681aea2f495/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9524464572e12979364b7d600abf96181d3541da11e23ddf565a32e70bd4dc0d", size = 80583, upload-time = "2021-12-01T09:09:19.546Z" },
{ url = "https://files.pythonhosted.org/packages/ec/f7/378254e6dd7ae6f31fe40c8649eea7d4832a42243acaf0f1fff9083b2bed/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b746dba803a79238e925d9046a63aa26bf86ab2a2fe74ce6b009a1c3f5c8f2ae", size = 86168, upload-time = "2021-12-01T09:09:21.445Z" },
{ url = "https://files.pythonhosted.org/packages/74/f6/4a34a37a98311ed73bb80efe422fed95f2ac25a4cacc5ae1d7ae6a144505/argon2_cffi_bindings-21.2.0-cp36-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58ed19212051f49a523abb1dbe954337dc82d947fb6e5a0da60f7c8471a8476c", size = 82709, upload-time = "2021-12-01T09:09:18.182Z" },
{ url = "https://files.pythonhosted.org/packages/74/2b/73d767bfdaab25484f7e7901379d5f8793cccbb86c6e0cbc4c1b96f63896/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:bd46088725ef7f58b5a1ef7ca06647ebaf0eb4baff7d1d0d177c6cc8744abd86", size = 83613, upload-time = "2021-12-01T09:09:22.741Z" },
{ url = "https://files.pythonhosted.org/packages/4f/fd/37f86deef67ff57c76f137a67181949c2d408077e2e3dd70c6c42912c9bf/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_i686.whl", hash = "sha256:8cd69c07dd875537a824deec19f978e0f2078fdda07fd5c42ac29668dda5f40f", size = 84583, upload-time = "2021-12-01T09:09:24.177Z" },
{ url = "https://files.pythonhosted.org/packages/6f/52/5a60085a3dae8fded8327a4f564223029f5f54b0cb0455a31131b5363a01/argon2_cffi_bindings-21.2.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f1152ac548bd5b8bcecfb0b0371f082037e47128653df2e8ba6e914d384f3c3e", size = 88475, upload-time = "2021-12-01T09:09:26.673Z" },
{ url = "https://files.pythonhosted.org/packages/8b/95/143cd64feb24a15fa4b189a3e1e7efbaeeb00f39a51e99b26fc62fbacabd/argon2_cffi_bindings-21.2.0-cp36-abi3-win32.whl", hash = "sha256:603ca0aba86b1349b147cab91ae970c63118a0f30444d4bc80355937c950c082", size = 27698, upload-time = "2021-12-01T09:09:27.87Z" },
{ url = "https://files.pythonhosted.org/packages/37/2c/e34e47c7dee97ba6f01a6203e0383e15b60fb85d78ac9a15cd066f6fe28b/argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl", hash = "sha256:b2ef1c30440dbbcba7a5dc3e319408b59676e2e039e2ae11a8775ecf482b192f", size = 30817, upload-time = "2021-12-01T09:09:30.267Z" },
{ url = "https://files.pythonhosted.org/packages/5a/e4/bf8034d25edaa495da3c8a3405627d2e35758e44ff6eaa7948092646fdcc/argon2_cffi_bindings-21.2.0-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:e415e3f62c8d124ee16018e491a009937f8cf7ebf5eb430ffc5de21b900dad93", size = 53104, upload-time = "2021-12-01T09:09:31.335Z" },
]
[[package]]
@@ -557,30 +557,30 @@ wheels = [
[[package]]
name = "boto3"
version = "1.40.1"
version = "1.39.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "botocore" },
{ name = "jmespath" },
{ name = "s3transfer" },
]
sdist = { url = "https://files.pythonhosted.org/packages/48/4d/70d209fdebf0377db233f80dfdf26ca2bc25d2b2e89d4882e0edccd2227f/boto3-1.40.1.tar.gz", hash = "sha256:985ed4bf64729807f870eadbc46ad98baf93096917f7194ec39d743ff75b3f1d", size = 111817, upload-time = "2025-08-01T19:24:18.017Z" }
sdist = { url = "https://files.pythonhosted.org/packages/63/65/ddd4f52d138e52c1345c2d2421281a98449a6e4365290477befe06fa649a/boto3-1.39.15.tar.gz", hash = "sha256:b4483625f0d8c35045254dee46cd3c851bbc0450814f20b9b25bee1b5c0d8409", size = 111856, upload-time = "2025-07-28T19:56:49.504Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/97/0e/f0cb4f71c40ba07e6ed5b47699a737a080d3c4f4b7b26657d5671de48621/boto3-1.40.1-py3-none-any.whl", hash = "sha256:7c007d5c8ee549e9fcad0927536502da199b27891006ef515330f429aca9671f", size = 139880, upload-time = "2025-08-01T19:24:16.581Z" },
{ url = "https://files.pythonhosted.org/packages/15/c5/27f50a31317041dc3ad79d62f37d5fcfb3f349c2fba8ea3e81de169db870/boto3-1.39.15-py3-none-any.whl", hash = "sha256:38fc54576b925af0075636752de9974e172c8a2cf7133400e3e09b150d20fb6a", size = 139901, upload-time = "2025-07-28T19:56:47.381Z" },
]
[[package]]
name = "botocore"
version = "1.40.1"
version = "1.39.15"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "jmespath" },
{ name = "python-dateutil" },
{ name = "urllib3" },
]
sdist = { url = "https://files.pythonhosted.org/packages/c6/d2/d914999f4a128f0f840f2a9cc8327cd98aa661d6b33b331a81a8111ab970/botocore-1.40.1.tar.gz", hash = "sha256:bdf30e2c0e8cdb939d81fc243182a6d1dd39c416694b406c5f2ea079b1c2f3f5", size = 14280398, upload-time = "2025-08-01T19:24:08.599Z" }
sdist = { url = "https://files.pythonhosted.org/packages/2f/e2/8cd9560e7e44cf977dc0cc2e48da7634e78b7104ae6e47f4e1dfc1093965/botocore-1.39.15.tar.gz", hash = "sha256:2aa29a717f14f8c7ca058c2e297aaed0aa10ecea24b91514eee802814d1b7600", size = 14237556, upload-time = "2025-07-28T19:56:39.397Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d4/c1/aa7922c9bf74b6d6594d2430af6f854d234faff23187e269aaba89c326c8/botocore-1.40.1-py3-none-any.whl", hash = "sha256:e039774b55fbd6fe59f0f4fea51d156a2433bd4d8faa64fc1b87aee9a03f415d", size = 13940950, upload-time = "2025-08-01T19:24:03.889Z" },
{ url = "https://files.pythonhosted.org/packages/7b/6e/f25b8633e7ab2008de4c27466c9bc39e32dc73816619ffebbea12936135a/botocore-1.39.15-py3-none-any.whl", hash = "sha256:eb9cfe918ebfbfb8654e1b153b29f0c129d586d2c0d7fb4032731d49baf04cff", size = 13894884, upload-time = "2025-07-28T19:56:33.715Z" },
]
[[package]]
@@ -1691,7 +1691,7 @@ wheels = [
[[package]]
name = "jsii"
version = "1.113.0"
version = "1.112.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "attrs" },
@@ -1702,9 +1702,9 @@ dependencies = [
{ name = "typeguard" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/37/9b/ff11800e2edc2860c9eddd7ea7c7a8849f69cbb16b1aae803dae7dafa86e/jsii-1.113.0.tar.gz", hash = "sha256:2dedea9d6006af53467a7a67f1d35a56ab3f75a3d6ed4b4536fffc3e1d1fe476", size = 623541, upload-time = "2025-07-31T12:55:42.888Z" }
sdist = { url = "https://files.pythonhosted.org/packages/ad/3e/270b5236035fc7bb2cdd7f55ea25f85489d35d971870cbec32c3d9e99d7f/jsii-1.112.0.tar.gz", hash = "sha256:6b7d19f361c2565b76828ecbe8cbed8b8d6028a82aa98a46b206a4ee5083157e", size = 624533, upload-time = "2025-05-07T14:45:52.574Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/4f/59/bbbdcc7e0adc32e2362dbb2398949ac013f79dc3468cdf2b5ac411b0f5e8/jsii-1.113.0-py3-none-any.whl", hash = "sha256:62377c651554234ea945693f7c03cb96a969ba425a686950c88d43b0d4d76b07", size = 599669, upload-time = "2025-07-31T12:55:40.874Z" },
{ url = "https://files.pythonhosted.org/packages/44/af/8554b632e2b82f37a7422782aba5db2a1fbff4887faa7ec850818def8407/jsii-1.112.0-py3-none-any.whl", hash = "sha256:6510c223074d9b206fd0570849a791e4d9ecfff7ffe68428de73870cea9f55a1", size = 600681, upload-time = "2025-05-07T14:45:51.136Z" },
]
[[package]]
@@ -2154,42 +2154,42 @@ source = { git = "https://github.com/vsoch/oci-python?rev=ceb4fcc090851717a3069d
[[package]]
name = "opentelemetry-api"
version = "1.36.0"
version = "1.35.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "importlib-metadata" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/27/d2/c782c88b8afbf961d6972428821c302bd1e9e7bc361352172f0ca31296e2/opentelemetry_api-1.36.0.tar.gz", hash = "sha256:9a72572b9c416d004d492cbc6e61962c0501eaf945ece9b5a0f56597d8348aa0", size = 64780, upload-time = "2025-07-29T15:12:06.02Z" }
sdist = { url = "https://files.pythonhosted.org/packages/99/c9/4509bfca6bb43220ce7f863c9f791e0d5001c2ec2b5867d48586008b3d96/opentelemetry_api-1.35.0.tar.gz", hash = "sha256:a111b959bcfa5b4d7dffc2fbd6a241aa72dd78dd8e79b5b1662bda896c5d2ffe", size = 64778, upload-time = "2025-07-11T12:23:28.804Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/bb/ee/6b08dde0a022c463b88f55ae81149584b125a42183407dc1045c486cc870/opentelemetry_api-1.36.0-py3-none-any.whl", hash = "sha256:02f20bcacf666e1333b6b1f04e647dc1d5111f86b8e510238fcc56d7762cda8c", size = 65564, upload-time = "2025-07-29T15:11:47.998Z" },
{ url = "https://files.pythonhosted.org/packages/1d/5a/3f8d078dbf55d18442f6a2ecedf6786d81d7245844b2b20ce2b8ad6f0307/opentelemetry_api-1.35.0-py3-none-any.whl", hash = "sha256:c4ea7e258a244858daf18474625e9cc0149b8ee354f37843415771a40c25ee06", size = 65566, upload-time = "2025-07-11T12:23:07.944Z" },
]
[[package]]
name = "opentelemetry-sdk"
version = "1.36.0"
version = "1.35.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "opentelemetry-api" },
{ name = "opentelemetry-semantic-conventions" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/4c/85/8567a966b85a2d3f971c4d42f781c305b2b91c043724fa08fd37d158e9dc/opentelemetry_sdk-1.36.0.tar.gz", hash = "sha256:19c8c81599f51b71670661ff7495c905d8fdf6976e41622d5245b791b06fa581", size = 162557, upload-time = "2025-07-29T15:12:16.76Z" }
sdist = { url = "https://files.pythonhosted.org/packages/9a/cf/1eb2ed2ce55e0a9aa95b3007f26f55c7943aeef0a783bb006bdd92b3299e/opentelemetry_sdk-1.35.0.tar.gz", hash = "sha256:2a400b415ab68aaa6f04e8a6a9f6552908fb3090ae2ff78d6ae0c597ac581954", size = 160871, upload-time = "2025-07-11T12:23:39.566Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0b/59/7bed362ad1137ba5886dac8439e84cd2df6d087be7c09574ece47ae9b22c/opentelemetry_sdk-1.36.0-py3-none-any.whl", hash = "sha256:19fe048b42e98c5c1ffe85b569b7073576ad4ce0bcb6e9b4c6a39e890a6c45fb", size = 119995, upload-time = "2025-07-29T15:12:03.181Z" },
{ url = "https://files.pythonhosted.org/packages/01/4f/8e32b757ef3b660511b638ab52d1ed9259b666bdeeceba51a082ce3aea95/opentelemetry_sdk-1.35.0-py3-none-any.whl", hash = "sha256:223d9e5f5678518f4842311bb73966e0b6db5d1e0b74e35074c052cd2487f800", size = 119379, upload-time = "2025-07-11T12:23:24.521Z" },
]
[[package]]
name = "opentelemetry-semantic-conventions"
version = "0.57b0"
version = "0.56b0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "opentelemetry-api" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/7e/31/67dfa252ee88476a29200b0255bda8dfc2cf07b56ad66dc9a6221f7dc787/opentelemetry_semantic_conventions-0.57b0.tar.gz", hash = "sha256:609a4a79c7891b4620d64c7aac6898f872d790d75f22019913a660756f27ff32", size = 124225, upload-time = "2025-07-29T15:12:17.873Z" }
sdist = { url = "https://files.pythonhosted.org/packages/32/8e/214fa817f63b9f068519463d8ab46afd5d03b98930c39394a37ae3e741d0/opentelemetry_semantic_conventions-0.56b0.tar.gz", hash = "sha256:c114c2eacc8ff6d3908cb328c811eaf64e6d68623840be9224dc829c4fd6c2ea", size = 124221, upload-time = "2025-07-11T12:23:40.71Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/05/75/7d591371c6c39c73de5ce5da5a2cc7b72d1d1cd3f8f4638f553c01c37b11/opentelemetry_semantic_conventions-0.57b0-py3-none-any.whl", hash = "sha256:757f7e76293294f124c827e514c2a3144f191ef175b069ce8d1211e1e38e9e78", size = 201627, upload-time = "2025-07-29T15:12:04.174Z" },
{ url = "https://files.pythonhosted.org/packages/c7/3f/e80c1b017066a9d999efffe88d1cce66116dcf5cb7f80c41040a83b6e03b/opentelemetry_semantic_conventions-0.56b0-py3-none-any.whl", hash = "sha256:df44492868fd6b482511cc43a942e7194be64e94945f572db24df2e279a001a2", size = 201625, upload-time = "2025-07-11T12:23:25.63Z" },
]
[[package]]

2
web/.gitignore vendored
View File

@@ -25,8 +25,6 @@ lib-cov
# Coverage directory used by tools like istanbul
coverage
playwright-report
test-results
*.lcov
# nyc test coverage

View File

@@ -1,90 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { LocatorContext } from "#e2e/selectors/types";
import { ConsoleLogger } from "#logger/node";
import { expect, Locator } from "@playwright/test";
import { kebabCase } from "change-case";
export type LocatorMatchers = ReturnType<typeof expect<Locator>>;
export interface LocatorProxy extends Pick<Locator, keyof Locator> {
$: Locator;
expect: LocatorMatchers;
}
// Type helpers to extract the shape of the proxy
export type DeepLocatorProxy<T> =
Disposable & T extends Record<string, any>
? T extends HTMLElement
? LocatorProxy
: {
[K in keyof T]: DeepLocatorProxy<T[K]>;
}
: LocatorProxy;
export function createLocatorProxy<T extends Record<string, any>>(
ctx: LocatorContext,
initialPathPrefix: string[] = [],
dataAttribute: string = "test-id",
): DeepLocatorProxy<T> {
dataAttribute = kebabCase(dataAttribute);
function createProxy(path: string[] = initialPathPrefix): any {
const proxyCache = new Map<string, LocatorProxy>();
return new Proxy({} as any, {
get(_, property: string) {
// Build the current path
const currentPath = [...path, property];
// Convert the path to kebab-case and join with hyphens
const selectorValue = currentPath.map((segment) => kebabCase(segment)).join("-");
const selector = `[data-${dataAttribute}="${selectorValue}"]`;
// Create a locator for the current selector
const locator = ctx.locator(selector);
if (proxyCache.has(selector)) {
ConsoleLogger.debug(`Using cached locator for ${selector}`);
return proxyCache.get(selector)!;
}
// Return a new proxy that also behaves like a Locator
// This allows us to either continue chaining or use Locator methods
const nextProxy = new Proxy(locator, {
get(target, prop) {
if (typeof prop === "string") {
// The user is likely trying to access a property on the page.
if (prop === "$") {
return target as any;
}
if (prop === "expect") {
return expect(target);
}
}
// If the property exists on the Locator, use it
if (prop in target) {
const value = (target as any)[prop];
// Bind methods to the locator instance
if (typeof value === "function") {
return value.bind(target);
}
return value;
}
// Otherwise, continue building the path
return createProxy(currentPath)[prop];
},
});
proxyCache.set(selector, nextProxy as LocatorProxy);
return nextProxy;
},
});
}
return createProxy() as DeepLocatorProxy<T>;
}

View File

@@ -1,6 +1,6 @@
import { PageFixture } from "#e2e/fixtures/PageFixture";
import { Page } from "@playwright/test";
import { expect, Page } from "@playwright/test";
export const GOOD_USERNAME = "test-admin@goauthentik.io";
export const GOOD_PASSWORD = "test-runner";
@@ -26,16 +26,21 @@ export class SessionFixture extends PageFixture {
/**
* The username field on the login page.
*/
public $usernameField = this.page.getByLabel("Username");
public $usernameField = this.$identificationStage.locator('input[name="uidField"]');
/**
* The button to continue with the login process,
* typically to the password flow stage.
*/
public $submitUsernameStageButton = this.$identificationStage.locator('button[type="submit"]');
public $passwordStage = this.page.locator("ak-stage-password");
public $passwordField = this.page.getByLabel("Password");
public $passwordField = this.$passwordStage.locator('input[name="password"]');
/**
* The button to submit the the login flow,
* typically redirecting to the authenticated interface.
*/
public $submitButton = this.page.locator('button[type="submit"]');
public $submitPasswordStageButton = this.$passwordStage.locator('button[type="submit"]');
/**
* A possible authentication failure message.
@@ -50,6 +55,26 @@ export class SessionFixture extends PageFixture {
//#region Specific interactions
public async submitUsernameStage(username: string) {
this.logger.info("Submitting username stage", username);
await this.$usernameField.fill(username);
await expect(this.$submitUsernameStageButton).toBeEnabled();
await this.$submitUsernameStageButton.click();
}
public async submitPasswordStage(password: string) {
this.logger.info("Submitting password stage");
await this.$passwordField.fill(password);
await expect(this.$submitPasswordStageButton).toBeEnabled();
await this.$submitPasswordStageButton.click();
}
public checkAuthenticated = async (): Promise<boolean> => {
// TODO: Check if the user is authenticated via API
return true;
@@ -73,19 +98,11 @@ export class SessionFixture extends PageFixture {
await this.page.goto(to.toString());
}
await this.$usernameField.fill(username);
await this.submitUsernameStage(username);
const passwordFieldVisible = await this.$passwordField.isVisible();
await this.$passwordField.waitFor({ state: "visible" });
if (!passwordFieldVisible) {
await this.$submitButton.click();
await this.$passwordField.waitFor({ state: "visible" });
}
await this.$passwordField.fill(password);
await this.$submitButton.click();
await this.submitPasswordStage(password);
const expectedPathname = typeof to === "string" ? to : to.pathname;

394
web/package-lock.json generated
View File

@@ -42,7 +42,6 @@
"@openlayers-elements/maps": "^0.4.0",
"@patternfly/elements": "^4.1.0",
"@patternfly/patternfly": "^4.224.2",
"@playwright/test": "^1.54.1",
"@sentry/browser": "^10.0.0",
"@spotlightjs/spotlight": "^3.0.1",
"@storybook/addon-docs": "^9.1.0",
@@ -58,7 +57,6 @@
"@types/react-dom": "^19.1.6",
"@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.38.0",
"@vitest/browser": "^3.2.4",
"@wdio/browser-runner": "^9.18.4",
"@wdio/cli": "9.15",
"@wdio/spec-reporter": "^9.15.0",
@@ -94,9 +92,6 @@
"md-front-matter": "^1.0.4",
"mermaid": "^11.9.0",
"npm-run-all": "^4.1.5",
"pino": "^9.7.0",
"pino-pretty": "^13.0.0",
"playwright": "^1.54.1",
"prettier": "^3.6.2",
"pseudolocale": "^2.1.0",
"rapidoc": "^9.3.8",
@@ -117,7 +112,6 @@
"turnstile-types": "^1.2.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.38.0",
"unique-names-generator": "^4.7.1",
"unist-util-visit": "^5.0.0",
"vite": "^7.0.6",
"vitest": "^3.2.4",
@@ -3900,27 +3894,6 @@
"url": "https://opencollective.com/pkgr"
}
},
"node_modules/@playwright/test": {
"version": "1.54.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.54.1.tgz",
"integrity": "sha512-FS8hQ12acieG2dYSksmLOF7BNxnVf2afRJdCuM1eMSxj6QTSE6G4InGF7oApGgDb65MX7AwMVlIkpru0yZA4Xw==",
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.54.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@polka/url": {
"version": "1.0.0-next.29",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz",
"integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==",
"license": "MIT"
},
"node_modules/@popperjs/core": {
"version": "2.11.8",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
@@ -5647,6 +5620,7 @@
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz",
"integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
@@ -5666,6 +5640,7 @@
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"peer": true,
"dependencies": {
"color-convert": "^2.0.1"
},
@@ -5681,6 +5656,7 @@
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"dequal": "^2.0.3"
}
@@ -5690,6 +5666,7 @@
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"license": "MIT",
"peer": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
@@ -5706,6 +5683,7 @@
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
@@ -5715,6 +5693,7 @@
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
@@ -5729,6 +5708,7 @@
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=10"
},
@@ -5740,13 +5720,15 @@
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"license": "MIT"
"license": "MIT",
"peer": true
},
"node_modules/@testing-library/dom/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"license": "MIT",
"peer": true,
"dependencies": {
"has-flag": "^4.0.0"
},
@@ -5754,19 +5736,6 @@
"node": ">=8"
}
},
"node_modules/@testing-library/user-event": {
"version": "14.6.1",
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.1.tgz",
"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==",
"license": "MIT",
"engines": {
"node": ">=12",
"npm": ">=6"
},
"peerDependencies": {
"@testing-library/dom": ">=7.21.4"
}
},
"node_modules/@tokenizer/token": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz",
@@ -5845,7 +5814,8 @@
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
"license": "MIT"
"license": "MIT",
"peer": true
},
"node_modules/@types/babel__code-frame": {
"version": "7.0.6",
@@ -6855,50 +6825,6 @@
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz",
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ=="
},
"node_modules/@vitest/browser": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/browser/-/browser-3.2.4.tgz",
"integrity": "sha512-tJxiPrWmzH8a+w9nLKlQMzAKX/7VjFs50MWgcAj7p9XQ7AQ9/35fByFYptgPELyLw+0aixTnC4pUWV+APcZ/kw==",
"license": "MIT",
"dependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/user-event": "^14.6.1",
"@vitest/mocker": "3.2.4",
"@vitest/utils": "3.2.4",
"magic-string": "^0.30.17",
"sirv": "^3.0.1",
"tinyrainbow": "^2.0.0",
"ws": "^8.18.2"
},
"funding": {
"url": "https://opencollective.com/vitest"
},
"peerDependencies": {
"playwright": "*",
"vitest": "3.2.4",
"webdriverio": "^7.0.0 || ^8.0.0 || ^9.0.0"
},
"peerDependenciesMeta": {
"playwright": {
"optional": true
},
"safaridriver": {
"optional": true
},
"webdriverio": {
"optional": true
}
}
},
"node_modules/@vitest/browser/node_modules/tinyrainbow": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz",
"integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/@vitest/expect": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz",
@@ -10423,15 +10349,6 @@
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/atomic-sleep": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
"integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==",
"license": "MIT",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
@@ -12575,15 +12492,6 @@
"node": ">=4.0"
}
},
"node_modules/dateformat": {
"version": "4.6.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz",
"integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==",
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/dayjs": {
"version": "1.11.13",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz",
@@ -13048,7 +12956,8 @@
"version": "0.5.16",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
"license": "MIT"
"license": "MIT",
"peer": true
},
"node_modules/dom-serializer": {
"version": "2.0.0",
@@ -15024,12 +14933,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/fast-copy": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.0.2.tgz",
"integrity": "sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==",
"license": "MIT"
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -15085,21 +14988,6 @@
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
},
"node_modules/fast-redact": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz",
"integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/fast-safe-stringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
"license": "MIT"
},
"node_modules/fast-xml-parser": {
"version": "5.2.5",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.2.5.tgz",
@@ -16415,12 +16303,6 @@
"he": "bin/he"
}
},
"node_modules/help-me": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz",
"integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==",
"license": "MIT"
},
"node_modules/highlight.js": {
"version": "11.11.1",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz",
@@ -17917,15 +17799,6 @@
"jiti": "bin/jiti.js"
}
},
"node_modules/joycon": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
"integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/jquery": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz",
@@ -18870,6 +18743,7 @@
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"license": "MIT",
"peer": true,
"bin": {
"lz-string": "bin/bin.js"
}
@@ -20608,15 +20482,6 @@
"node": ">=4"
}
},
"node_modules/mrmime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
"integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -21307,15 +21172,6 @@
"ol": "^7.3.0"
}
},
"node_modules/on-exit-leak-free": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz",
"integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
@@ -21884,73 +21740,6 @@
"node": ">=4"
}
},
"node_modules/pino": {
"version": "9.7.0",
"resolved": "https://registry.npmjs.org/pino/-/pino-9.7.0.tgz",
"integrity": "sha512-vnMCM6xZTb1WDmLvtG2lE/2p+t9hDEIvTWJsu6FejkE62vB7gDhvzrpFR4Cw2to+9JNQxVnkAKVPA1KPB98vWg==",
"license": "MIT",
"dependencies": {
"atomic-sleep": "^1.0.0",
"fast-redact": "^3.1.1",
"on-exit-leak-free": "^2.1.0",
"pino-abstract-transport": "^2.0.0",
"pino-std-serializers": "^7.0.0",
"process-warning": "^5.0.0",
"quick-format-unescaped": "^4.0.3",
"real-require": "^0.2.0",
"safe-stable-stringify": "^2.3.1",
"sonic-boom": "^4.0.1",
"thread-stream": "^3.0.0"
},
"bin": {
"pino": "bin.js"
}
},
"node_modules/pino-abstract-transport": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz",
"integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==",
"license": "MIT",
"dependencies": {
"split2": "^4.0.0"
}
},
"node_modules/pino-pretty": {
"version": "13.0.0",
"resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.0.0.tgz",
"integrity": "sha512-cQBBIVG3YajgoUjo1FdKVRX6t9XPxwB9lcNJVD5GCnNM4Y6T12YYx8c6zEejxQsU0wrg9TwmDulcE9LR7qcJqA==",
"license": "MIT",
"dependencies": {
"colorette": "^2.0.7",
"dateformat": "^4.6.3",
"fast-copy": "^3.0.2",
"fast-safe-stringify": "^2.1.1",
"help-me": "^5.0.0",
"joycon": "^3.1.1",
"minimist": "^1.2.6",
"on-exit-leak-free": "^2.1.0",
"pino-abstract-transport": "^2.0.0",
"pump": "^3.0.0",
"secure-json-parse": "^2.4.0",
"sonic-boom": "^4.0.1",
"strip-json-comments": "^3.1.1"
},
"bin": {
"pino-pretty": "bin.js"
}
},
"node_modules/pino-pretty/node_modules/colorette": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
"license": "MIT"
},
"node_modules/pino-std-serializers": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz",
"integrity": "sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==",
"license": "MIT"
},
"node_modules/piscina": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/piscina/-/piscina-4.7.0.tgz",
@@ -21976,50 +21765,6 @@
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"license": "MIT"
},
"node_modules/playwright": {
"version": "1.54.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.54.1.tgz",
"integrity": "sha512-peWpSwIBmSLi6aW2auvrUtf2DqY16YYcCMO8rTVx486jKmDTJg7UAhyrraP98GB8BoPURZP8+nxO7TSd4cPr5g==",
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.54.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.54.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.54.1.tgz",
"integrity": "sha512-Nbjs2zjj0htNhzgiy5wu+3w09YetDx5pkrpI/kZotDlDUaYk0HVA5xrBVPdow4SAUIlhgKcJeJg4GRKW6xHusA==",
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/playwright/node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/points-on-curve": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz",
@@ -22242,22 +21987,6 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"node_modules/process-warning": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz",
"integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "MIT"
},
"node_modules/progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
@@ -22486,12 +22215,6 @@
}
]
},
"node_modules/quick-format-unescaped": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz",
"integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==",
"license": "MIT"
},
"node_modules/quick-lru": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
@@ -22937,15 +22660,6 @@
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/real-require": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz",
"integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==",
"license": "MIT",
"engines": {
"node": ">= 12.13.0"
}
},
"node_modules/recast": {
"version": "0.23.9",
"resolved": "https://registry.npmjs.org/recast/-/recast-0.23.9.tgz",
@@ -23945,15 +23659,6 @@
"node": ">=10"
}
},
"node_modules/safe-stable-stringify": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
"integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/safe-stringify": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/safe-stringify/-/safe-stringify-1.1.1.tgz",
@@ -23982,12 +23687,6 @@
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
"optional": true
},
"node_modules/secure-json-parse": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz",
"integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==",
"license": "BSD-3-Clause"
},
"node_modules/seek-bzip": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-2.0.0.tgz",
@@ -24265,20 +23964,6 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/sirv": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz",
"integrity": "sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==",
"license": "MIT",
"dependencies": {
"@polka/url": "^1.0.0-next.24",
"mrmime": "^2.0.0",
"totalist": "^3.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/slash": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz",
@@ -24378,15 +24063,6 @@
"node": ">= 14"
}
},
"node_modules/sonic-boom": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.0.tgz",
"integrity": "sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==",
"license": "MIT",
"dependencies": {
"atomic-sleep": "^1.0.0"
}
},
"node_modules/sort-asc": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/sort-asc/-/sort-asc-0.1.0.tgz",
@@ -24686,6 +24362,19 @@
"yarn": ">=1"
}
},
"node_modules/storybook/node_modules/@testing-library/user-event": {
"version": "14.6.1",
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.1.tgz",
"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==",
"license": "MIT",
"engines": {
"node": ">=12",
"npm": ">=6"
},
"peerDependencies": {
"@testing-library/dom": ">=7.21.4"
}
},
"node_modules/storybook/node_modules/@vitest/spy": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz",
@@ -25403,15 +25092,6 @@
"b4a": "^1.6.4"
}
},
"node_modules/thread-stream": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.1.0.tgz",
"integrity": "sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==",
"license": "MIT",
"dependencies": {
"real-require": "^0.2.0"
}
},
"node_modules/through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
@@ -25529,15 +25209,6 @@
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==",
"license": "MIT"
},
"node_modules/totalist": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz",
"integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/tr46": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz",
@@ -26065,15 +25736,6 @@
"@types/estree": "^1.0.0"
}
},
"node_modules/unique-names-generator": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-4.7.1.tgz",
"integrity": "sha512-lMx9dX+KRmG8sq6gulYYpKWZc9RlGsgBR6aoO8Qsm3qvkSJ+3rAymr+TnV8EDMrIrwuFJ4kruzMWM/OpYzPoow==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/unist-util-find-after": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz",

View File

@@ -24,8 +24,8 @@
"pseudolocalize": "node ./scripts/pseudolocalize.mjs",
"storybook": "storybook dev -p 6006",
"storybook:build": "wireit",
"test": "vitest",
"test:e2e": "playwright test",
"test": "wireit",
"test:e2e": "wireit",
"test:e2e:watch": "wireit",
"test:watch": "wireit",
"tsc": "wireit",
@@ -69,9 +69,6 @@
"#flow/*": "./src/flow/*.js",
"#locales/*": "./src/locales/*.js",
"#stories/*": "./src/stories/*.js",
"#tests/*": "./tests/*.js",
"#e2e": "./e2e/index.ts",
"#e2e/*": "./e2e/*.ts",
"#*/browser": {
"types": "./out/*/browser.d.ts",
"import": "./*/browser.js"
@@ -116,7 +113,6 @@
"@openlayers-elements/maps": "^0.4.0",
"@patternfly/elements": "^4.1.0",
"@patternfly/patternfly": "^4.224.2",
"@playwright/test": "^1.54.1",
"@sentry/browser": "^10.0.0",
"@spotlightjs/spotlight": "^3.0.1",
"@storybook/addon-docs": "^9.1.0",
@@ -132,7 +128,6 @@
"@types/react-dom": "^19.1.6",
"@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.38.0",
"@vitest/browser": "^3.2.4",
"@wdio/browser-runner": "^9.18.4",
"@wdio/cli": "9.15",
"@wdio/spec-reporter": "^9.15.0",
@@ -168,9 +163,6 @@
"md-front-matter": "^1.0.4",
"mermaid": "^11.9.0",
"npm-run-all": "^4.1.5",
"pino": "^9.7.0",
"pino-pretty": "^13.0.0",
"playwright": "^1.54.1",
"prettier": "^3.6.2",
"pseudolocale": "^2.1.0",
"rapidoc": "^9.3.8",
@@ -191,7 +183,6 @@
"turnstile-types": "^1.2.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.38.0",
"unique-names-generator": "^4.7.1",
"unist-util-visit": "^5.0.0",
"vite": "^7.0.6",
"vitest": "^3.2.4",
@@ -278,7 +269,7 @@
"command": "lit-analyzer src"
},
"lint:types:tests": {
"command": "tsc --noEmit -p tsconfig.test.json"
"command": "tsc --noEmit -p ./tests"
},
"lint:types": {
"command": "tsc -p .",
@@ -327,7 +318,7 @@
],
"env": {
"CI": "true",
"TS_NODE_PROJECT": "tsconfig.test.json"
"TS_NODE_PROJECT": "./tests/tsconfig.test.json"
}
},
"test:e2e:watch": {
@@ -336,7 +327,7 @@
"build"
],
"env": {
"TS_NODE_PROJECT": "tsconfig.test.json"
"TS_NODE_PROJECT": "./tests/tsconfig.test.json"
}
},
"test:watch": {

View File

@@ -5,10 +5,6 @@ import { groupBy } from "#common/utils";
import { AKElement } from "#elements/Base";
import { AKLabel } from "#components/ak-label";
import { IDGenerator } from "#packages/core/id";
import { Provider, ProvidersAllListRequest, ProvidersApi } from "@goauthentik/api";
import { html, nothing } from "lit";
@@ -42,48 +38,37 @@ export class AkProviderInput extends AKElement {
return this;
}
//#region Properties
@property({ type: String })
name!: string;
@property({ type: String })
public name!: string;
@property({ type: String })
public label?: string;
label = "";
@property({ type: Number })
public value?: number;
value?: number;
@property({ type: Boolean })
public required = false;
required = false;
@property({ type: Boolean })
public blankable = false;
blankable = false;
@property({ type: String })
public help?: string;
help = "";
/**
* A unique ID to associate with the input and label.
* @property
*/
@property({ type: String, reflect: false })
protected fieldID = IDGenerator.elementID().toString();
constructor() {
super();
this.selected = this.selected.bind(this);
}
//#endregion
#selected = (item: Provider) => {
return typeof this.value === "number" && this.value === item.pk;
};
selected(item: Provider) {
return this.value !== undefined && this.value === item.pk;
}
render() {
return html` <ak-form-element-horizontal name=${this.name}>
<div slot="label" class="pf-c-form__group-label">
${AKLabel({ htmlFor: this.fieldID, required: this.required }, this.label)}
</div>
return html` <ak-form-element-horizontal label=${this.label} name=${this.name}>
<ak-search-select
.fieldID=${this.fieldID}
.selected=${this.#selected}
.selected=${this.selected}
.fetchObjects=${fetch}
.renderElement=${renderElement}
.value=${renderValue}

View File

@@ -135,8 +135,7 @@ export class ApplicationWizardApplicationStep extends ApplicationWizardStep {
name="group"
value=${ifDefined(app.group)}
label=${msg("Group")}
placeholder=${msg("e.g. Collaboration, Communication, Internal, etc.")}
.errorMessages=${errors.group}
.errorMessages=${errors.group ?? []}
help=${msg(
"Optionally enter a group name. Applications with identical groups are shown grouped together.",
)}
@@ -148,7 +147,7 @@ export class ApplicationWizardApplicationStep extends ApplicationWizardStep {
name="policyEngineMode"
.options=${policyEngineModes}
.value=${app.policyEngineMode}
.errorMessages=${errors.policyEngineMode}
.errorMessages=${errors.policyEngineMode ?? []}
></ak-radio-input>
<ak-form-group label=${msg("UI Settings")}>
<div class="pf-c-form">

View File

@@ -50,12 +50,13 @@ export class CoreGroupSearch extends CustomListenerElement(AKElement) {
search!: SearchSelect<Group>;
@property({ type: String })
public name?: string | null;
name: string | null | undefined;
selectedGroup?: Group;
constructor() {
super();
this.selected = this.selected.bind(this);
this.handleSearchUpdate = this.handleSearchUpdate.bind(this);
}
@@ -82,9 +83,9 @@ export class CoreGroupSearch extends CustomListenerElement(AKElement) {
this.dispatchEvent(new InputEvent("input", { bubbles: true, composed: true }));
}
selected = (group: Group) => {
selected(group: Group) {
return this.group === group.pk;
};
}
render() {
return html`

View File

@@ -40,13 +40,7 @@ export class AkCryptoCertificateSearch extends CustomListenerElement(AKElement)
search!: SearchSelect<CertificateKeyPair>;
@property({ type: String })
public name?: string | null;
@property({ type: String })
public label?: string | undefined;
@property({ type: String })
public placeholder?: string | undefined;
name: string | null | undefined;
/**
* Set to `true` to allow certificates without private key to show up. When set to `false`,
@@ -54,7 +48,7 @@ export class AkCryptoCertificateSearch extends CustomListenerElement(AKElement)
* @attr
*/
@property({ type: Boolean, attribute: "nokey" })
public noKey = false;
noKey = false;
/**
* Set this to true if, should there be only one certificate available, you want the system to
@@ -63,12 +57,16 @@ export class AkCryptoCertificateSearch extends CustomListenerElement(AKElement)
* @attr
*/
@property({ type: Boolean, attribute: "singleton" })
public singleton = false;
singleton = false;
/**
* @todo Document this.
*/
public selectedKeypair?: CertificateKeyPair;
selectedKeypair?: CertificateKeyPair;
constructor() {
super();
this.selected = this.selected.bind(this);
this.fetchObjects = this.fetchObjects.bind(this);
this.handleSearchUpdate = this.handleSearchUpdate.bind(this);
}
get value() {
return this.selectedKeypair ? renderValue(this.selectedKeypair) : null;
@@ -87,13 +85,13 @@ export class AkCryptoCertificateSearch extends CustomListenerElement(AKElement)
}
}
handleSearchUpdate = (ev: CustomEvent) => {
handleSearchUpdate(ev: CustomEvent) {
ev.stopPropagation();
this.selectedKeypair = ev.detail.value;
this.dispatchEvent(new InputEvent("input", { bubbles: true, composed: true }));
};
}
fetchObjects = async (query?: string): Promise<CertificateKeyPair[]> => {
async fetchObjects(query?: string): Promise<CertificateKeyPair[]> {
const args: CryptoCertificatekeypairsListRequest = {
ordering: "name",
hasKey: !this.noKey,
@@ -106,21 +104,19 @@ export class AkCryptoCertificateSearch extends CustomListenerElement(AKElement)
args,
);
return certificates.results;
};
}
selected = (item: CertificateKeyPair, items: CertificateKeyPair[]) => {
selected(item: CertificateKeyPair, items: CertificateKeyPair[]) {
return (
(this.singleton && !this.certificate && items.length === 1) ||
(!!this.certificate && this.certificate === item.pk)
);
};
}
render() {
return html`
<ak-search-select
name=${ifDefined(this.name ?? undefined)}
label=${ifDefined(this.label ?? undefined)}
placeholder=${ifDefined(this.placeholder)}
.fetchObjects=${this.fetchObjects}
.renderElement=${renderElement}
.value=${renderValue}

View File

@@ -3,7 +3,6 @@ import "#elements/forms/SearchSelect/index";
import { DEFAULT_CONFIG } from "#common/api/config";
import { AKElement } from "#elements/Base";
import type { HorizontalFormElement } from "#elements/forms/HorizontalFormElement";
import { SearchSelect } from "#elements/forms/SearchSelect/index";
import { CustomListenerElement } from "#elements/utils/eventEmitter";
@@ -12,7 +11,6 @@ import { RenderFlowOption } from "#admin/flows/utils";
import type { Flow, FlowsInstancesListRequest } from "@goauthentik/api";
import { FlowsApi, FlowsInstancesListDesignationEnum } from "@goauthentik/api";
import { msg } from "@lit/localize";
import { html } from "lit";
import { property, query } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
@@ -35,17 +33,17 @@ export function getFlowValue(flow: Flow | undefined): string | undefined {
* A wrapper around SearchSelect that understands the basic semantics of querying about Flows. This
* code eliminates the long blocks of unreadable invocation that were embedded in every provider, as well as in
* sources, brands, and applications.
*
*/
export abstract class FlowSearch<T extends Flow> extends CustomListenerElement(AKElement) {
//#region Properties
export class FlowSearch<T extends Flow> extends CustomListenerElement(AKElement) {
/**
* The type of flow we're looking for.
*
* @attr
*/
@property({ type: String })
public flowType?: FlowsInstancesListDesignationEnum;
flowType?: FlowsInstancesListDesignationEnum;
/**
* The id of the current flow, if any. For stages where the flow is already defined.
@@ -53,7 +51,7 @@ export abstract class FlowSearch<T extends Flow> extends CustomListenerElement(A
* @attr
*/
@property({ type: String })
public currentFlow?: string;
currentFlow?: string | undefined;
/**
* If true, it is not valid to leave the flow blank.
@@ -61,7 +59,10 @@ export abstract class FlowSearch<T extends Flow> extends CustomListenerElement(A
* @attr
*/
@property({ type: Boolean })
public required?: boolean;
required?: boolean = false;
@query("ak-search-select")
search!: SearchSelect<T>;
/**
* When specified and the object instance does not have a flow selected, auto-select the flow with the given slug.
@@ -69,118 +70,66 @@ export abstract class FlowSearch<T extends Flow> extends CustomListenerElement(A
* @attr
*/
@property()
public defaultFlowSlug?: string;
defaultFlowSlug?: string;
@property({ type: String })
public name?: string;
name: string | null | undefined;
/**
* The label of the input, for forms.
*
* @attr
*/
@property({ type: String })
public label?: string;
/**
* The textual placeholder for the search's <input> object, if currently empty. Used as the
* native <input> object's `placeholder` field.
*
* @attr
*/
@property({ type: String })
public placeholder = msg("Select a flow...");
@query("ak-search-select")
protected search!: SearchSelect<T>;
protected selectedFlow?: T;
selectedFlow?: T;
get value() {
return this.selectedFlow ? getFlowValue(this.selectedFlow) : null;
}
//#endregion
//#region Event Listeners
protected searchUpdateListener = (event: CustomEvent) => {
event.stopPropagation();
this.selectedFlow = event.detail.value;
constructor() {
super();
this.fetchObjects = this.fetchObjects.bind(this);
this.selected = this.selected.bind(this);
this.handleSearchUpdate = this.handleSearchUpdate.bind(this);
}
handleSearchUpdate(ev: CustomEvent) {
ev.stopPropagation();
this.selectedFlow = ev.detail.value;
this.dispatchEvent(new InputEvent("input", { bubbles: true, composed: true }));
};
}
//#endregion
//#region Lifecycle
/**
* Fetch the objects from the API.
*
* @param query The search query, if any.
*/
protected fetchObjects = (query?: string): Promise<Flow[]> => {
async fetchObjects(query?: string): Promise<Flow[]> {
const args: FlowsInstancesListRequest = {
ordering: "slug",
designation: this.flowType,
...(query ? { search: query } : {}),
...(query !== undefined ? { search: query } : {}),
};
const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(args);
return flows.results;
}
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(args).then((flows) => flows.results);
};
/**
* Determine if the flow matches the current state of the search.
*
* @param flow The flow to compare against.
/* This is the most commonly overridden method of this class. About half of the Flow Searches
* use this method, but several have more complex needs, such as relating to the brand, or just
* returning false.
*/
protected match = (flow: Flow): boolean => {
if (this.currentFlow) {
return this.currentFlow === flow.pk;
selected(flow: Flow): boolean {
let selected = this.currentFlow === flow.pk;
if (!this.currentFlow && this.defaultFlowSlug && flow.slug === this.defaultFlowSlug) {
selected = true;
}
return selected;
}
return !!(this.defaultFlowSlug && flow.slug === this.defaultFlowSlug);
};
/**
* This is the most commonly overridden method of this class.
*
* About half of the Flow Searches use this method, but several have more complex needs,
* such as relating to the brand, or just returning false.
*
* @param flow The flow to compare against.
* @abstract
*/
protected selected = (flow: Flow): boolean => {
return this.match(flow);
};
public override connectedCallback() {
connectedCallback() {
super.connectedCallback();
const horizontalContainer = this.closest<HorizontalFormElement>(
"ak-form-element-horizontal[name]",
);
const horizontalContainer = this.closest("ak-form-element-horizontal[name]");
if (!horizontalContainer) {
throw new Error("This search can only be used in a named ak-form-element-horizontal");
}
const name = horizontalContainer.getAttribute("name");
const myName = this.getAttribute("name");
if (name !== null && name !== myName) {
this.setAttribute("name", name);
}
}
//#endregion
//#region Render
public override render() {
render() {
return html`
<ak-search-select
.fetchObjects=${this.fetchObjects}
@@ -188,15 +137,13 @@ export abstract class FlowSearch<T extends Flow> extends CustomListenerElement(A
.renderElement=${renderElement}
.renderDescription=${renderDescription}
.value=${getFlowValue}
placeholder=${ifDefined(this.placeholder)}
label=${ifDefined(this.label)}
name=${ifDefined(this.name)}
@ak-change=${this.searchUpdateListener}
name=${ifDefined(this.name ?? undefined)}
@ak-change=${this.handleSearchUpdate}
?blankable=${!this.required}
>
</ak-search-select>
`;
}
//#endregion
}
export default FlowSearch;

View File

@@ -1,4 +1,4 @@
import { FlowSearch } from "./FlowSearch.js";
import FlowSearch from "./FlowSearch.js";
import type { Flow } from "@goauthentik/api";
@@ -19,11 +19,16 @@ export class AkBrandedFlowSearch<T extends Flow> extends FlowSearch<T> {
* @attr
*/
@property({ attribute: false, type: String })
public brandFlow?: string;
brandFlow?: string;
protected override selected = (flow: Flow): boolean => {
return this.match(flow) || flow.pk === this.brandFlow;
};
constructor() {
super();
this.selected = this.selected.bind(this);
}
selected(flow: Flow): boolean {
return super.selected(flow) || flow.pk === this.brandFlow;
}
}
declare global {

View File

@@ -24,7 +24,7 @@ export class AkFlowSearchNoDefault<T extends Flow> extends FlowSearch<T> {
.renderElement=${renderElement}
.renderDescription=${renderDescription}
.value=${getFlowValue}
@ak-change=${this.searchUpdateListener}
@ak-change=${this.handleSearchUpdate}
?blankable=${!this.required}
>
</ak-search-select>

View File

@@ -1,4 +1,4 @@
import { FlowSearch } from "./FlowSearch.js";
import FlowSearch from "./FlowSearch.js";
import type { Flow } from "@goauthentik/api";
@@ -18,3 +18,5 @@ declare global {
"ak-flow-search": AkFlowSearch<Flow>;
}
}
export default AkFlowSearch;

View File

@@ -1,4 +1,4 @@
import { FlowSearch } from "./FlowSearch.js";
import FlowSearch from "./FlowSearch.js";
import type { Flow } from "@goauthentik/api";
@@ -18,8 +18,9 @@ export class AkSourceFlowSearch<T extends Flow> extends FlowSearch<T> {
*
* @attr
*/
@property({ type: String })
public fallback?: string;
fallback: string | undefined;
/**
* The primary key of the Source (not the Flow). Mostly the instancePk itself, used to affirm
@@ -28,16 +29,21 @@ export class AkSourceFlowSearch<T extends Flow> extends FlowSearch<T> {
* @attr
*/
@property({ type: String })
public instanceId?: string;
instanceId: string | undefined;
constructor() {
super();
this.selected = this.selected.bind(this);
}
// If there's no instance or no currentFlowId for it and the flow resembles the fallback,
// otherwise defer to the parent class.
protected override selected = (flow: Flow): boolean => {
selected(flow: Flow): boolean {
return (
(!this.instanceId && !this.currentFlow && flow.slug === this.fallback) ||
this.match(flow)
super.selected(flow)
);
};
}
}
declare global {

View File

@@ -51,7 +51,7 @@ export function renderForm(
placeholder=${msg("Provider name")}
value=${ifDefined(provider?.name)}
label=${msg("Name")}
.errorMessages=${errors?.name}
.errorMessages=${errors?.name ?? []}
required
help=${msg("Method's display Name.")}
></ak-text-input>
@@ -87,7 +87,7 @@ export function renderForm(
label=${msg("Bind flow")}
required
name="authorizationFlow"
.errorMessages=${errors?.authorizationFlow}
.errorMessages=${errors?.authorizationFlow ?? []}
>
<ak-branded-flow-search
label=${msg("Bind flow")}
@@ -111,7 +111,7 @@ export function renderForm(
.currentFlow=${provider?.invalidationFlow}
.brandFlow=${brand?.flowInvalidation}
defaultFlowSlug="default-invalidation-flow"
.errorMessages=${errors?.invalidationFlow}
.errorMessages=${errors?.invalidationFlow ?? []}
required
></ak-branded-flow-search>
<p class="pf-c-form__helper-text">${msg("Flow used for unbinding users.")}</p>
@@ -127,7 +127,7 @@ export function renderForm(
required
value="${provider?.baseDn ?? "DC=ldap,DC=goauthentik,DC=io"}"
input-hint="code"
.errorMessages=${errors?.baseDn}
.errorMessages=${errors?.baseDn ?? []}
help=${msg(
"LDAP DN under which bind requests and search requests can be made.",
)}
@@ -137,11 +137,9 @@ export function renderForm(
<ak-form-element-horizontal
label=${msg("Certificate")}
name="certificate"
.errorMessages=${errors?.certificate}
.errorMessages=${errors?.certificate ?? []}
>
<ak-crypto-certificate-search
label=${msg("Certificate")}
placeholder=${msg("Select a certificate...")}
certificate=${ifDefined(provider?.certificate ?? nothing)}
name="certificate"
>
@@ -153,7 +151,7 @@ export function renderForm(
label=${msg("TLS Server name")}
name="tlsServerName"
value="${provider?.tlsServerName ?? ""}"
.errorMessages=${errors?.tlsServerName}
.errorMessages=${errors?.tlsServerName ?? []}
help=${tlsServerNameHelp}
input-hint="code"
></ak-text-input>
@@ -163,7 +161,7 @@ export function renderForm(
required
name="uidStartNumber"
value="${provider?.uidStartNumber ?? 2000}"
.errorMessages=${errors?.uidStartNumber}
.errorMessages=${errors?.uidStartNumber ?? []}
help=${uidStartNumberHelp}
></ak-number-input>
@@ -172,7 +170,7 @@ export function renderForm(
required
name="gidStartNumber"
value="${provider?.gidStartNumber ?? 4000}"
.errorMessages=${errors?.gidStartNumber}
.errorMessages=${errors?.gidStartNumber ?? []}
help=${gidStartNumberHelp}
></ak-number-input>
</div>

View File

@@ -124,10 +124,8 @@ export function renderForm(
) {
return html` <ak-text-input
name="name"
placeholder=${msg("Provider name")}
label=${msg("Name")}
value=${ifDefined(provider?.name)}
.errorMessages=${errors?.name}
required
></ak-text-input>
@@ -137,11 +135,8 @@ export function renderForm(
required
>
<ak-flow-search
label=${msg("Authorization flow")}
placeholder=${msg("Select an authorization flow...")}
flowType=${FlowsInstancesListDesignationEnum.Authorization}
.currentFlow=${provider?.authorizationFlow}
.errorMessages=${errors?.authorizationFlow}
required
></ak-flow-search>
<p class="pf-c-form__helper-text">
@@ -167,7 +162,6 @@ export function renderForm(
value="${provider?.clientId ?? randomString(40, ascii_letters + digits)}"
required
input-hint="code"
.errorMessages=${errors?.clientId}
>
</ak-text-input>
<ak-hidden-text-input
@@ -180,6 +174,7 @@ export function renderForm(
>
</ak-hidden-text-input>
<ak-form-element-horizontal
flow-direction="row"
label=${msg("Redirect URIs/Origins (RegEx)")}
name="redirectUris"
>
@@ -202,8 +197,6 @@ export function renderForm(
<ak-form-element-horizontal label=${msg("Signing Key")} name="signingKey">
<!-- NOTE: 'null' cast to 'undefined' on signingKey to satisfy Lit requirements -->
<ak-crypto-certificate-search
label=${msg("Signing Key")}
placeholder=${msg("Select a signing key...")}
certificate=${ifDefined(provider?.signingKey ?? undefined)}
singleton
></ak-crypto-certificate-search>
@@ -212,8 +205,6 @@ export function renderForm(
<ak-form-element-horizontal label=${msg("Encryption Key")} name="encryptionKey">
<!-- NOTE: 'null' cast to 'undefined' on encryptionKey to satisfy Lit requirements -->
<ak-crypto-certificate-search
label=${msg("Encryption Key")}
placeholder=${msg("Select an encryption key...")}
certificate=${ifDefined(provider?.encryptionKey ?? undefined)}
></ak-crypto-certificate-search>
<p class="pf-c-form__helper-text">${msg("Key used to encrypt the tokens.")}</p>
@@ -228,8 +219,6 @@ export function renderForm(
label=${msg("Authentication flow")}
>
<ak-flow-search
label=${msg("Authentication flow")}
placeholder=${msg("Select an authentication flow...")}
flowType=${FlowsInstancesListDesignationEnum.Authentication}
.currentFlow=${provider?.authenticationFlow}
></ak-flow-search>
@@ -245,8 +234,6 @@ export function renderForm(
required
>
<ak-flow-search
label=${msg("Invalidation flow")}
placeholder=${msg("Select an invalidation flow...")}
flowType=${FlowsInstancesListDesignationEnum.Invalidation}
.currentFlow=${provider?.invalidationFlow}
defaultFlowSlug="default-provider-invalidation-flow"

View File

@@ -26,7 +26,6 @@ import {
RbacPermissionsAssignedByUsersListModelEnum,
User,
} from "@goauthentik/api";
import { IDGenerator } from "@goauthentik/core/id";
import MDProviderOAuth2 from "~docs/add-secure-apps/providers/oauth2/index.mdx";
@@ -268,16 +267,12 @@ export class OAuth2ProviderViewPage extends AKElement {
<div class="pf-c-card__body">
<form class="pf-c-form">
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("providerInfo")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text"
>${msg("OpenID Configuration URL")}</span
>
</label>
<input
id="${IDGenerator.elementID("providerInfo")}"
class="pf-c-form-control"
readonly
type="text"
@@ -285,16 +280,12 @@ export class OAuth2ProviderViewPage extends AKElement {
/>
</div>
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("issuer")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text"
>${msg("OpenID Configuration Issuer")}</span
>
</label>
<input
id="${IDGenerator.elementID("issuer")}"
class="pf-c-form-control"
readonly
type="text"
@@ -303,16 +294,12 @@ export class OAuth2ProviderViewPage extends AKElement {
</div>
<hr class="pf-c-divider" />
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("authorize")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text"
>${msg("Authorize URL")}</span
>
</label>
<input
id="${IDGenerator.elementID("authorize")}"
class="pf-c-form-control"
readonly
type="text"
@@ -320,14 +307,10 @@ export class OAuth2ProviderViewPage extends AKElement {
/>
</div>
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("token")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${msg("Token URL")}</span>
</label>
<input
id="${IDGenerator.elementID("token")}"
class="pf-c-form-control"
readonly
type="text"
@@ -335,16 +318,12 @@ export class OAuth2ProviderViewPage extends AKElement {
/>
</div>
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("userInfo")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text"
>${msg("Userinfo URL")}</span
>
</label>
<input
id="${IDGenerator.elementID("userInfo")}"
class="pf-c-form-control"
readonly
type="text"
@@ -352,14 +331,10 @@ export class OAuth2ProviderViewPage extends AKElement {
/>
</div>
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("logout")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${msg("Logout URL")}</span>
</label>
<input
id="${IDGenerator.elementID("logout")}"
class="pf-c-form-control"
readonly
type="text"
@@ -367,14 +342,10 @@ export class OAuth2ProviderViewPage extends AKElement {
/>
</div>
<div class="pf-c-form__group">
<label
class="pf-c-form__label"
for="${IDGenerator.elementID("jwks")}"
>
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${msg("JWKS URL")}</span>
</label>
<input
id="${IDGenerator.elementID("jwks")}"
class="pf-c-form-control"
readonly
type="text"
@@ -420,12 +391,9 @@ export class OAuth2ProviderViewPage extends AKElement {
${renderDescriptionList(
[
[
html`<label for="${IDGenerator.elementID("preview-user")}"
>${msg("Preview for user")}</label
>`,
msg("Preview for user"),
html`
<ak-search-select
id="${IDGenerator.elementID("preview-user")}"
.fetchObjects=${async (query?: string): Promise<User[]> => {
const args: CoreUsersListRequest = {
ordering: "username",

View File

@@ -88,7 +88,7 @@ function renderProxySettings(provider: Partial<ProxyProvider>, errors?: Validati
label=${msg("External host")}
value="${ifDefined(provider?.externalHost)}"
required
.errorMessages=${errors?.externalHost}
.errorMessages=${errors?.externalHost ?? []}
help=${msg(
"The external URL you'll access the application at. Include any non-standard port.",
)}
@@ -99,7 +99,7 @@ function renderProxySettings(provider: Partial<ProxyProvider>, errors?: Validati
label=${msg("Internal host")}
value="${ifDefined(provider?.internalHost)}"
required
.errorMessages=${errors?.internalHost}
.errorMessages=${errors?.internalHost ?? []}
help=${msg("Upstream host that the requests are forwarded to.")}
input-hint="code"
></ak-text-input>
@@ -124,7 +124,7 @@ function renderForwardSingleSettings(provider: Partial<ProxyProvider>, errors?:
label=${msg("External host")}
value="${ifDefined(provider?.externalHost)}"
required
.errorMessages=${errors?.externalHost}
.errorMessages=${errors?.externalHost ?? []}
help=${msg(
"The external URL you'll access the application at. Include any non-standard port.",
)}
@@ -154,7 +154,7 @@ function renderForwardDomainSettings(provider: Partial<ProxyProvider>, errors?:
label=${msg("Authentication URL")}
value="${provider?.externalHost ?? window.location.origin}"
required
.errorMessages=${errors?.externalHost}
.errorMessages=${errors?.externalHost ?? []}
help=${msg(
"The external URL you'll authenticate at. The authentik core server should be reachable under this URL.",
)}
@@ -165,7 +165,7 @@ function renderForwardDomainSettings(provider: Partial<ProxyProvider>, errors?:
name="cookieDomain"
value="${ifDefined(provider?.cookieDomain)}"
required
.errorMessages=${errors?.cookieDomain}
.errorMessages=${errors?.cookieDomain ?? []}
help=${msg(
"Set this to the domain you wish the authentication to be valid for. Must be a parent domain of the URL above. If you're running applications as app1.domain.tld, app2.domain.tld, set this to 'domain.tld'.",
)}
@@ -196,7 +196,7 @@ export function renderForm(
name="name"
value=${ifDefined(provider?.name)}
label=${msg("Name")}
.errorMessages=${errors?.name}
.errorMessages=${errors?.name ?? []}
required
></ak-text-input>
@@ -224,7 +224,7 @@ export function renderForm(
label=${msg("Token validity")}
name="accessTokenValidity"
value="${provider?.accessTokenValidity ?? "hours=24"}"
.errorMessages=${errors?.accessTokenValidity}
.errorMessages=${errors?.accessTokenValidity ?? []}
required
.help=${msg("Configure how long tokens are valid for.")}
input-hint="code"

View File

@@ -45,9 +45,8 @@ export function renderForm(
<ak-text-input
name="name"
label=${msg("Name")}
placeholder=${msg("Provider name")}
value=${ifDefined(provider?.name)}
.errorMessages=${errors?.name}
.errorMessages=${errors?.name ?? []}
required
>
</ak-text-input>
@@ -56,11 +55,9 @@ export function renderForm(
label=${msg("Authentication flow")}
required
name="authorizationFlow"
.errorMessages=${errors?.authorizationFlow}
.errorMessages=${errors?.authorizationFlow ?? []}
>
<ak-branded-flow-search
label=${msg("Authentication flow")}
placeholder=${msg("Select an authentication flow...")}
flowType=${FlowsInstancesListDesignationEnum.Authentication}
.currentFlow=${provider?.authorizationFlow}
.brandFlow=${brand?.flowAuthentication}
@@ -82,7 +79,7 @@ export function renderForm(
<ak-hidden-text-input
name="sharedSecret"
label=${msg("Shared secret")}
.errorMessages=${errors?.sharedSecret}
.errorMessages=${errors?.sharedSecret ?? []}
value=${provider?.sharedSecret ?? randomString(128, ascii_letters + digits)}
required
input-hint="code"
@@ -91,7 +88,7 @@ export function renderForm(
name="clientNetworks"
label=${msg("Client Networks")}
value=${provider?.clientNetworks ?? "0.0.0.0/0, ::/0"}
.errorMessages=${errors?.clientNetworks}
.errorMessages=${errors?.clientNetworks ?? []}
required
help=${clientNetworksHelp}
input-hint="code"
@@ -121,7 +118,7 @@ export function renderForm(
placeholder=${msg("Select an invalidation flow...")}
flowType=${FlowsInstancesListDesignationEnum.Invalidation}
.currentFlow=${provider?.invalidationFlow}
.errorMessages=${errors?.invalidationFlow}
.errorMessages=${errors?.invalidationFlow ?? []}
defaultFlowSlug="default-invalidation-flow"
required
></ak-flow-search>

View File

@@ -12,8 +12,6 @@ import { digestAlgorithmOptions, signatureAlgorithmOptions } from "./SAMLProvide
import { DEFAULT_CONFIG } from "#common/api/config";
import { RadioOption } from "#elements/forms/Radio";
import {
FlowsInstancesListDesignationEnum,
PropertymappingsApi,
@@ -28,7 +26,7 @@ import { msg } from "@lit/localize";
import { html, nothing } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
const serviceProviderBindingOptions: RadioOption<SpBindingEnum>[] = [
const serviceProviderBindingOptions = [
{
label: msg("Redirect"),
value: SpBindingEnum.Redirect,
@@ -40,11 +38,11 @@ const serviceProviderBindingOptions: RadioOption<SpBindingEnum>[] = [
},
];
function renderHasSigningKp(provider: Partial<SAMLProvider>) {
function renderHasSigningKp(provider?: Partial<SAMLProvider>) {
return html` <ak-switch-input
name="signAssertion"
label=${msg("Sign assertions")}
?checked=${provider.signAssertion ?? true}
?checked=${provider?.signAssertion ?? true}
help=${msg("When enabled, the assertion element of the SAML response will be signed.")}
>
</ak-switch-input>
@@ -52,7 +50,7 @@ function renderHasSigningKp(provider: Partial<SAMLProvider>) {
<ak-switch-input
name="signResponse"
label=${msg("Sign responses")}
?checked=${provider.signResponse ?? false}
?checked=${provider?.signResponse ?? false}
help=${msg("When enabled, the SAML response will be signed.")}
>
</ak-switch-input>`;
@@ -66,10 +64,10 @@ export function renderForm(
) {
return html` <ak-text-input
name="name"
value=${ifDefined(provider.name)}
value=${ifDefined(provider?.name)}
label=${msg("Name")}
required
.errorMessages=${errors?.name}
.errorMessages=${errors?.name ?? []}
></ak-text-input>
<ak-form-element-horizontal
name="authorizationFlow"
@@ -78,9 +76,9 @@ export function renderForm(
>
<ak-flow-search
flowType=${FlowsInstancesListDesignationEnum.Authorization}
.currentFlow=${provider.authorizationFlow}
.errorMessages=${errors?.authorizationFlow}
.currentFlow=${provider?.authorizationFlow}
required
.errorMessages=${errors?.authorizationFlow ?? []}
></ak-flow-search>
<p class="pf-c-form__helper-text">
${msg("Flow used when authorizing this provider.")}
@@ -92,16 +90,16 @@ export function renderForm(
<ak-text-input
name="acsUrl"
label=${msg("ACS URL")}
value="${ifDefined(provider.acsUrl)}"
value="${ifDefined(provider?.acsUrl)}"
required
.errorMessages=${errors?.acsUrl}
.errorMessages=${errors?.acsUrl ?? []}
></ak-text-input>
<ak-text-input
label=${msg("Issuer")}
name="issuer"
value="${provider.issuer || "authentik"}"
value="${provider?.issuer || "authentik"}"
required
.errorMessages=${errors?.issuer}
.errorMessages=${errors?.issuer ?? []}
help=${msg("Also known as EntityID.")}
></ak-text-input>
<ak-radio-input
@@ -109,7 +107,7 @@ export function renderForm(
name="spBinding"
required
.options=${serviceProviderBindingOptions}
.value=${provider.spBinding}
.value=${provider?.spBinding}
help=${msg(
"Determines how authentik sends the response back to the Service Provider.",
)}
@@ -118,8 +116,8 @@ export function renderForm(
<ak-text-input
name="audience"
label=${msg("Audience")}
value="${ifDefined(provider.audience)}"
.errorMessages=${errors?.audience}
value="${ifDefined(provider?.audience)}"
.errorMessages=${errors?.audience ?? []}
></ak-text-input>
</div>
</ak-form-group>
@@ -132,7 +130,7 @@ export function renderForm(
>
<ak-flow-search
flowType=${FlowsInstancesListDesignationEnum.Authentication}
.currentFlow=${provider.authenticationFlow}
.currentFlow=${provider?.authenticationFlow}
></ak-flow-search>
<p class="pf-c-form__helper-text">
${msg(
@@ -147,7 +145,7 @@ export function renderForm(
>
<ak-flow-search
flowType=${FlowsInstancesListDesignationEnum.Invalidation}
.currentFlow=${provider.invalidationFlow}
.currentFlow=${provider?.invalidationFlow}
defaultFlowSlug="default-provider-invalidation-flow"
required
></ak-flow-search>
@@ -162,7 +160,7 @@ export function renderForm(
<div class="pf-c-form">
<ak-form-element-horizontal label=${msg("Signing Certificate")} name="signingKp">
<ak-crypto-certificate-search
.certificate=${provider.signingKp}
.certificate=${provider?.signingKp}
@input=${setHasSigningKp}
></ak-crypto-certificate-search>
<p class="pf-c-form__helper-text">
@@ -178,7 +176,7 @@ export function renderForm(
name="verificationKp"
>
<ak-crypto-certificate-search
.certificate=${provider.verificationKp}
.certificate=${provider?.verificationKp}
nokey
></ak-crypto-certificate-search>
<p class="pf-c-form__helper-text">
@@ -192,7 +190,7 @@ export function renderForm(
name="encryptionKp"
>
<ak-crypto-certificate-search
.certificate=${provider.encryptionKp}
.certificate=${provider?.encryptionKp}
></ak-crypto-certificate-search>
<p class="pf-c-form__helper-text">
${msg("When selected, assertions will be encrypted using this keypair.")}
@@ -204,7 +202,7 @@ export function renderForm(
>
<ak-dual-select-dynamic-selected
.provider=${propertyMappingsProvider}
.selector=${propertyMappingsSelector(provider.propertyMappings)}
.selector=${propertyMappingsSelector(provider?.propertyMappings)}
available-label=${msg("Available User Property Mappings")}
selected-label=${msg("Selected User Property Mappings")}
></ak-dual-select-dynamic-selected>
@@ -214,7 +212,6 @@ export function renderForm(
name="nameIdMapping"
>
<ak-search-select
required
.fetchObjects=${async (query?: string): Promise<SAMLPropertyMapping[]> => {
const args: PropertymappingsProviderSamlListRequest = {
ordering: "saml_name",
@@ -234,7 +231,7 @@ export function renderForm(
return item?.pk;
}}
.selected=${(item: SAMLPropertyMapping): boolean => {
return provider.nameIdMapping === item.pk;
return provider?.nameIdMapping === item.pk;
}}
blankable
>
@@ -250,7 +247,6 @@ export function renderForm(
name="authnContextClassRefMapping"
>
<ak-search-select
required
.fetchObjects=${async (query?: string): Promise<SAMLPropertyMapping[]> => {
const args: PropertymappingsProviderSamlListRequest = {
ordering: "saml_name",
@@ -270,7 +266,7 @@ export function renderForm(
return item?.pk;
}}
.selected=${(item: SAMLPropertyMapping): boolean => {
return provider.authnContextClassRefMapping === item.pk;
return provider?.authnContextClassRefMapping === item.pk;
}}
blankable
>
@@ -285,35 +281,35 @@ export function renderForm(
<ak-text-input
name="assertionValidNotBefore"
label=${msg("Assertion valid not before")}
value="${provider.assertionValidNotBefore || "minutes=-5"}"
value="${provider?.assertionValidNotBefore || "minutes=-5"}"
required
.errorMessages=${errors?.assertionValidNotBefore}
.errorMessages=${errors?.assertionValidNotBefore ?? []}
help=${msg("Configure the maximum allowed time drift for an assertion.")}
></ak-text-input>
<ak-text-input
name="assertionValidNotOnOrAfter"
label=${msg("Assertion valid not on or after")}
value="${provider.assertionValidNotOnOrAfter || "minutes=5"}"
value="${provider?.assertionValidNotOnOrAfter || "minutes=5"}"
required
.errorMessages=${errors?.assertionValidNotBefore}
.errorMessages=${errors?.assertionValidNotBefore ?? []}
help=${msg("Assertion not valid on or after current time + this value.")}
></ak-text-input>
<ak-text-input
name="sessionValidNotOnOrAfter"
label=${msg("Session valid not on or after")}
value="${provider.sessionValidNotOnOrAfter || "minutes=86400"}"
value="${provider?.sessionValidNotOnOrAfter || "minutes=86400"}"
required
.errorMessages=${errors?.sessionValidNotOnOrAfter}
.errorMessages=${errors?.sessionValidNotOnOrAfter ?? []}
help=${msg("Session not valid on or after current time + this value.")}
></ak-text-input>
<ak-text-input
name="defaultRelayState"
label=${msg("Default relay state")}
value="${provider.defaultRelayState || ""}"
.errorMessages=${errors?.sessionValidNotOnOrAfter}
value="${provider?.defaultRelayState || ""}"
.errorMessages=${errors?.sessionValidNotOnOrAfter ?? []}
help=${msg(
"When using IDP-initiated logins, the relay state will be set to this value.",
)}
@@ -323,7 +319,7 @@ export function renderForm(
name="digestAlgorithm"
label=${msg("Digest algorithm")}
.options=${digestAlgorithmOptions}
.value=${provider.digestAlgorithm}
.value=${provider?.digestAlgorithm}
required
>
</ak-radio-input>
@@ -332,7 +328,7 @@ export function renderForm(
name="signatureAlgorithm"
label=${msg("Signature algorithm")}
.options=${signatureAlgorithmOptions}
.value=${provider.signatureAlgorithm}
.value=${provider?.signatureAlgorithm}
required
>
</ak-radio-input>

View File

@@ -28,7 +28,7 @@ export function renderForm(provider?: Partial<SCIMProvider>, errors: ValidationE
name="name"
value=${ifDefined(provider?.name)}
label=${msg("Name")}
.errorMessages=${errors?.name}
.errorMessages=${errors?.name ?? []}
required
help=${msg("Method's display Name.")}
></ak-text-input>
@@ -38,7 +38,7 @@ export function renderForm(provider?: Partial<SCIMProvider>, errors: ValidationE
name="url"
label=${msg("URL")}
value="${provider?.url ?? ""}"
.errorMessages=${errors?.url}
.errorMessages=${errors?.url ?? []}
required
help=${msg("SCIM base url, usually ends in /v2.")}
input-hint="code"
@@ -55,7 +55,7 @@ export function renderForm(provider?: Partial<SCIMProvider>, errors: ValidationE
name="token"
label=${msg("Token")}
value="${provider?.token ?? ""}"
.errorMessages=${errors?.token}
.errorMessages=${errors?.token ?? []}
required
help=${msg(
"Token to authenticate with. Currently only bearer authentication is supported.",

View File

@@ -74,8 +74,8 @@ export class InitialPermissionsForm extends ModelForm<InitialPermissions, string
if (query !== undefined) {
args.search = query;
}
const roles = await new RbacApi(DEFAULT_CONFIG).rbacRolesList(args);
return roles.results;
const users = await new RbacApi(DEFAULT_CONFIG).rbacRolesList(args);
return users.results;
}}
.renderElement=${(role: Role): string => {
return role.name;

View File

@@ -171,10 +171,6 @@ export function pluckErrorDetail(errorLike: unknown, fallback?: string): string
ResponseErrorMessages[HTTPStatusCode.InternalServiceError],
);
if (errorLike && typeof errorLike === "string") {
return errorLike;
}
if (!errorLike || typeof errorLike !== "object") {
return fallback;
}

View File

@@ -35,24 +35,6 @@
--ak-navbar--height: 7rem;
}
.pf-c-form__group {
--pf-c-form--m-horizontal__group-label--md--GridColumnWidth: minmax(max-content, 9.375rem);
column-gap: var(--pf-global--spacer--md);
}
.pf-c-form__group-label {
user-select: none;
padding-top: var(--pf-c-form--m-horizontal__group-label--md--PaddingTop);
}
.pf-c-form__label[aria-required] .pf-c-form__label-text::after {
content: "*";
user-select: none;
margin-left: var(--pf-c-form__label-required--MarginLeft);
font-size: var(--pf-c-form__label-required--FontSize);
color: var(--pf-c-form__label-required--Color);
}
@supports selector(::-webkit-scrollbar) {
::-webkit-scrollbar {
width: 5px;

View File

@@ -292,7 +292,7 @@ export function applyDocumentTheme(hint: CSSColorSchemeValue | UIThemeHint = "au
* @todo Can this be handled with a Lit Mixin?
*/
export function rootInterface<T extends HTMLElement = HTMLElement>(): T {
const element = document.body.querySelector<T>("[data-test-id=interface-root]");
const element = document.body.querySelector<T>("[data-ak-interface-root]");
if (!element) {
throw new Error(

View File

@@ -1,14 +1,10 @@
import { SlottedTemplateResult } from "#elements/types";
import { html, nothing, TemplateResult } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { map } from "lit/directives/map.js";
export type DescriptionPair = [
term: SlottedTemplateResult,
desc: SlottedTemplateResult | undefined,
];
export type DescriptionRecord = { term: string; desc: SlottedTemplateResult | undefined };
export type DescriptionDesc = string | TemplateResult | undefined | typeof nothing;
export type DescriptionPair = [string, DescriptionDesc];
export type DescriptionRecord = { term: string; desc: DescriptionDesc };
interface DescriptionConfig {
horizontal?: boolean;

View File

@@ -4,13 +4,11 @@ import { SlottedTemplateResult } from "../elements/types";
import { AKElement, type AKElementProps } from "#elements/Base";
import { ErrorProp } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { IDGenerator } from "@goauthentik/core/id";
import { html, nothing, TemplateResult } from "lit";
import { property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
export interface HorizontalLightComponentProps<T> extends AKElementProps {
name: string;
@@ -20,7 +18,7 @@ export interface HorizontalLightComponentProps<T> extends AKElementProps {
bighelp?: SlottedTemplateResult | SlottedTemplateResult[];
hidden?: boolean;
invalid?: boolean;
errorMessages?: ErrorProp[];
errorMessages?: string[];
value?: T;
inputHint?: string;
}
@@ -40,15 +38,13 @@ export abstract class HorizontalLightComponent<T>
return this;
}
//#region Properties
/**
* The name attribute for the form element
* @property
* @attribute
*/
@property({ type: String, reflect: true })
public name!: string;
name!: string;
/**
* The label for the input control
@@ -56,14 +52,14 @@ export abstract class HorizontalLightComponent<T>
* @attribute
*/
@property({ type: String, reflect: true })
public label?: string;
label?: string;
/**
* @property
* @attribute
*/
@property({ type: Boolean, reflect: true })
public required = false;
required = false;
/**
* Help text to display below the form element. Optional
@@ -71,40 +67,41 @@ export abstract class HorizontalLightComponent<T>
* @attribute
*/
@property({ type: String, reflect: true })
public help = "";
help = "";
/**
* Extended help content. Optional. Expects to be a TemplateResult
* @property
*/
@property({ type: Object })
public bighelp?: TemplateResult | TemplateResult[];
bighelp?: TemplateResult | TemplateResult[];
/**
* @property
* @attribute
*/
@property({ type: Boolean, reflect: true })
public hidden = false;
hidden = false;
/**
* @property
* @attribute
*/
@property({ type: Boolean, reflect: true })
public invalid = false;
invalid = false;
/**
* @property
*/
@property({ attribute: false })
public errorMessages?: ErrorProp[];
errorMessages: string[] = [];
/**
* @attribute
* @property
*/
@property({ attribute: false })
public value?: T;
value?: T;
/**
* Input hint.
@@ -113,24 +110,14 @@ export abstract class HorizontalLightComponent<T>
* @attribute
*/
@property({ type: String, attribute: "input-hint" })
public inputHint?: string;
inputHint?: string;
protected renderControl() {
throw new Error("Must be implemented in a subclass");
}
/**
* A unique ID to associate with the input and label.
* @property
*/
@property({ type: String, reflect: false })
protected fieldID = IDGenerator.elementID().toString();
//#endregion
//#region Rendering
/**
* Render the control element, e.g. an input, textarea, select, etc.
*/
protected abstract renderControl(): SlottedTemplateResult;
protected renderHelp(): SlottedTemplateResult | SlottedTemplateResult[] {
const bigHelp: SlottedTemplateResult[] = Array.isArray(this.bighelp)
? this.bighelp
@@ -144,20 +131,15 @@ export abstract class HorizontalLightComponent<T>
render() {
return html`<ak-form-element-horizontal
.fieldID=${this.fieldID}
fieldID=${this.fieldID}
label=${ifDefined(this.label)}
?required=${this.required}
?hidden=${this.hidden}
name=${this.name}
.errorMessages=${this.errorMessages}
?invalid=${this.invalid}
>
<div slot="label" class="pf-c-form__group-label">
${AKLabel({ htmlFor: this.fieldID, required: this.required }, this.label)}
</div>
${this.renderControl()} ${this.renderHelp()}
</ak-form-element-horizontal> `;
}
//#endregion
}

View File

@@ -1,45 +0,0 @@
import { pluckErrorDetail } from "#common/errors/network";
import { LitFC } from "#elements/types";
import { ErrorDetail, ValidationError } from "@goauthentik/api";
import { msg, str } from "@lit/localize";
import { html, nothing } from "lit";
/**
* An error originating from a form field.
*/
export type FieldErrorTuple = [fieldName: string, detail: string];
export type ErrorProp = string | Error | ErrorDetail | ValidationError | FieldErrorTuple;
export interface AKFormErrorsProps {
errors?: ErrorProp[];
}
function renderError(detail: string) {
if (!detail) {
return nothing;
}
return html`<p class="pf-c-form__helper-text pf-m-error" aria-live="polite">
<span class="pf-c-form__helper-text-icon">
<i class="fas fa-exclamation-circle" aria-hidden="true"></i> </span
>${detail}
</p>`;
}
export const AKFormErrors: LitFC<AKFormErrorsProps> = ({ errors } = {}) => {
if (!errors?.length) return nothing;
return errors.flatMap((error) => {
if (Array.isArray(error) && error.length === 2) {
const [fieldName, detail] = error;
return renderError(msg(str`${fieldName}: ${detail}`));
}
return renderError(pluckErrorDetail(error));
});
};

View File

@@ -1,32 +1,67 @@
import { HorizontalLightComponent } from "#components/HorizontalLightComponent";
import { AKElement } from "#elements/Base";
import { html } from "lit";
import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { createRef, ref } from "lit/directives/ref.js";
import { msg } from "@lit/localize";
import { html, nothing } from "lit";
import { customElement, property, query } from "lit/decorators.js";
@customElement("ak-file-input")
export class AkFileInput extends HorizontalLightComponent<string> {
#inputRef = createRef<HTMLInputElement>();
get files(): Iterable<File> {
return this.#inputRef.value?.files || [];
export class AkFileInput extends AKElement {
// Render into the lightDOM. This effectively erases the shadowDOM nature of this component, but
// we're not actually using that and, for the meantime, we need the form handlers to be able to
// find the children of this component.
//
// TODO: This abstraction is wrong; it's putting *more* layers in as a way of managing the
// visual clutter and legibility issues of ak-form-elemental-horizontal and patternfly in
// general.
protected createRenderRoot() {
return this;
}
#inputListener(ev: InputEvent) {
this.value = (ev.target as HTMLInputElement).value;
@property({ type: String })
name!: string;
@property({ type: String })
label = "";
/*
* The message to show next to the "current icon".
*
* @attr
*/
@property({ type: String })
current = msg("Currently set to:");
@property({ type: String })
value = "";
@property({ type: Boolean })
required = false;
@property({ type: String })
help = "";
@query('input[type="file"]')
input!: HTMLInputElement;
get files() {
return this.input.files;
}
public override renderControl() {
return html` <input
${ref(this.#inputRef)}
id=${ifDefined(this.fieldID)}
type="file"
@input=${this.#inputListener}
value=${ifDefined(this.value)}
class="pf-c-form-control"
?required=${ifDefined(this.required)}
/>`;
render() {
const currentMsg =
this.value && this.current
? html` <p class="pf-c-form__helper-text">${this.current} ${this.value}</p> `
: nothing;
return html`<ak-form-element-horizontal
?required="${this.required}"
label=${this.label}
name=${this.name}
>
<input type="file" value="" class="pf-c-form-control" />
${currentMsg}
${this.help.trim() ? html`<p class="pf-c-form__helper-text">${this.help}</p>` : nothing}
</ak-form-element-horizontal>`;
}
}

View File

@@ -8,12 +8,12 @@ import {
import { msg } from "@lit/localize";
import { css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { customElement, property, query } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { ifDefined } from "lit/directives/if-defined.js";
type BaseProps = HorizontalLightComponentProps<string> &
Pick<VisibilityToggleProps, "hideContentLabel" | "revealContentLabel">;
Pick<VisibilityToggleProps, "showMessage" | "hideMessage">;
export interface AkHiddenTextInputProps extends BaseProps {
revealed: boolean;
@@ -53,13 +53,10 @@ export class AkHiddenTextInput<T extends InputLike = HTMLInputElement>
* @property
* @attribute
*/
@property({ type: String, reflect: true })
public value = "";
/**
* Whether the input value is visible.
*
* @property
* @attribute
*/
@@ -67,7 +64,7 @@ export class AkHiddenTextInput<T extends InputLike = HTMLInputElement>
public revealed = false;
/**
* Placeholder text when no value is set.
* Text for when the input has no set value
*
* @property
* @attribute
@@ -76,7 +73,16 @@ export class AkHiddenTextInput<T extends InputLike = HTMLInputElement>
public placeholder?: string;
/**
* Specify kind of help the browser should try to provide.
* Text for when the input has no set value
*
* @property
* @attribute
*/
@property({ type: String })
public label?: string;
/**
* Specify kind of help the browser should try to provide
*
* @property
* @attribute
@@ -89,37 +95,29 @@ export class AkHiddenTextInput<T extends InputLike = HTMLInputElement>
* @attribute
*/
@property({ type: String, attribute: "show-message" })
public revealContentLabel = msg("Show field content");
public showMessage = msg("Show field content");
/**
* @property
* @attribute
*/
@property({ type: String, attribute: "hide-message" })
public hideContentLabel = msg("Hide field content");
public hideMessage = msg("Hide field content");
/**
* A listener for the input event.
*/
protected inputListener = (event: InputEvent) => {
this.value = (event.target as T).value;
};
/**
* Render the input field.
*
* TODO: Because of the peculiarities of how HorizontalLightComponent works, keeping its content LightDOM so the inner components actually inherit styling, the normal `css` options aren't available. Embedding styles is bad styling, and we'll fix it in the next style refresh.
*/
protected renderInputField() {
const code = this.inputHint === "code";
@query("#main > input")
protected inputField!: T;
// TODO: Because of the peculiarities of how HorizontalLightComponent works, keeping its content
// in the LightDom so the inner components actually inherit styling, the normal `css` options
// aren't available. Embedding styles is bad styling, and we'll fix it in the next style
// refresh.
protected renderInputField(setValue: InputListener, code: boolean) {
return html` <input
part="input"
id=${ifDefined(this.fieldID)}
autocomplete=${ifDefined(this.autocomplete)}
type=${this.revealed ? "text" : "password"}
aria-label=${ifDefined(this.label)}
@input=${this.inputListener}
@input=${setValue}
value=${ifDefined(this.value)}
placeholder=${ifDefined(this.placeholder)}
class="${classMap({
@@ -132,14 +130,19 @@ export class AkHiddenTextInput<T extends InputLike = HTMLInputElement>
}
protected override renderControl() {
const code = this.inputHint === "code";
const setValue: InputListener = (ev) => {
this.value = (ev.target as T).value;
};
return html` <div style="display: flex; gap: 0.25rem">
${this.renderInputField()}
${this.renderInputField(setValue, code)}
<ak-visibility-toggle
part="toggle"
style="flex: 0 0 auto; align-self: flex-start"
?open=${this.revealed}
show-message=${this.revealContentLabel}
hide-message=${this.hideContentLabel}
show-message=${this.showMessage}
hide-message=${this.hideMessage}
@click=${() => (this.revealed = !this.revealed)}
></ak-visibility-toggle>
</div>`;

View File

@@ -1,7 +1,11 @@
import { AkHiddenTextInput, type AkHiddenTextInputProps } from "./ak-hidden-text-input.js";
import {
AkHiddenTextInput,
type AkHiddenTextInputProps,
InputListener,
} from "./ak-hidden-text-input.js";
import { html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { customElement, property, query } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { ifDefined } from "lit/directives/if-defined.js";
@@ -44,44 +48,43 @@ export class AkHiddenTextAreaInput
extends AkHiddenTextInput<HTMLTextAreaElement>
implements AkHiddenTextAreaInputProps
{
//#region Properties
/* These are mostly just forwarded to the textarea component. */
/**
* Number of visible text lines (rows)
*
* @property
* @attribute
*/
@property({ type: Number })
public rows?: number = 4;
rows?: number = 4;
/**
* Nummber of visible character width (cols)
* @property
* @attribute
*/
@property({ type: Number })
public cols?: number;
cols?: number;
/**
* You want `resize=true` so that the resize value is visible in the component tag, activating the CSS associated with these values.
*
* @property
* @attribute
*
* You want `resize=true` so that the resize value is visible in the component tag, activating
* the CSS associated with these values.
*/
@property({ type: String, reflect: true })
public resize?: "none" | "both" | "horizontal" | "vertical" = "vertical";
resize?: "none" | "both" | "horizontal" | "vertical" = "vertical";
/**
* @property
* @attribute
*/
@property({ type: String })
public wrap?: "soft" | "hard" | "off" = "soft";
wrap?: "soft" | "hard" | "off" = "soft";
//#endregion
@query("#main > textarea")
protected inputField!: HTMLTextAreaElement;
get #visibleValue() {
get displayValue() {
const value = this.value ?? "";
if (this.revealed) {
return value;
@@ -93,18 +96,18 @@ export class AkHiddenTextAreaInput
.join("\n");
}
//#region Rendering
protected override renderInputField() {
// TODO: Because of the peculiarities of how HorizontalLightComponent works, keeping its content
// in the LightDom so the inner components actually inherit styling, the normal `css` options
// aren't available. Embedding styles is bad styling, and we'll fix it in the next style
// refresh.
protected override renderInputField(setValue: InputListener, code: boolean) {
const wrap = this.revealed ? this.wrap : "soft";
const code = this.inputHint === "code";
return html`
<textarea
style="flex: 1 1 auto; min-width: 0;"
part="textarea"
@input=${this}
id=${ifDefined(this.fieldID)}
@input=${setValue}
placeholder=${ifDefined(this.placeholder)}
aria-label=${ifDefined(this.label)}
rows=${ifDefined(this.rows)}
@@ -117,12 +120,10 @@ export class AkHiddenTextAreaInput
spellcheck=${code ? "false" : "true"}
?required=${this.required}
>
${this.#visibleValue}</textarea
${this.displayValue}</textarea
>
`;
}
//#endregion
}
declare global {

View File

@@ -1,27 +0,0 @@
import { LitFC } from "#elements/types";
import { spread } from "@open-wc/lit-helpers";
import type { LabelHTMLAttributes } from "react";
import { html, nothing } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
export interface FormLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
required?: boolean;
}
export const AKLabel: LitFC<FormLabelProps> = (
{ required, htmlFor, ...labelAttributes } = {},
children,
) => {
if (!children) return nothing;
return html`<label
class="pf-c-form__label"
for=${ifDefined(htmlFor)}
?aria-required=${required}
${spread(labelAttributes)}
>
<span class="pf-c-form__label-text">${children}</span>
</label>`;
};

View File

@@ -1,5 +1,7 @@
import { HorizontalLightComponent } from "./HorizontalLightComponent.js";
import { bound } from "#elements/decorators/bound";
import { kebabCase } from "change-case";
import { html } from "lit";
@@ -54,7 +56,7 @@ export class AkSlugInput extends HorizontalLightComponent<string> {
// Do not stop propagation of this event; it must be sent up the tree so that a parent
// component, such as a custom forms manager, may receive it.
#touchListener = (ev: Event) => {
protected handleTouch(ev: Event) {
this.value = this.input.value = slugify(this.input.value);
// Reset 'touched' status if the slug & target have been reset
@@ -66,9 +68,10 @@ export class AkSlugInput extends HorizontalLightComponent<string> {
if (ev && ev.target && ev.target instanceof HTMLInputElement) {
this.#touched = true;
}
};
}
#slugify = (ev: Event) => {
@bound
protected slugify(ev: Event) {
if (!(ev && ev.target && ev.target instanceof HTMLInputElement)) {
return;
}
@@ -111,18 +114,18 @@ export class AkSlugInput extends HorizontalLightComponent<string> {
cancelable: true,
}),
);
};
}
public override disconnectedCallback() {
this.#origin?.removeEventListener("input", this.#slugify);
if (this.#origin) {
this.#origin.removeEventListener("input", this.slugify);
}
super.disconnectedCallback();
}
public override renderControl() {
return html`<input
id=${ifDefined(this.fieldID)}
@input=${this.#touchListener}
@input=${(ev: Event) => this.handleTouch(ev)}
type="text"
value=${ifDefined(this.value)}
class="pf-c-form-control"
@@ -140,7 +143,7 @@ export class AkSlugInput extends HorizontalLightComponent<string> {
this.#origin = rootNode.querySelector(this.source);
}
if (this.#origin) {
this.#origin.addEventListener("input", this.#slugify);
this.#origin.addEventListener("input", this.slugify);
}
}
}

View File

@@ -44,8 +44,6 @@ export class AkSwitchInput extends AKElement {
const helpText = this.help.trim();
return html` <ak-form-element-horizontal name=${this.name} ?required=${this.required}>
<div slot="label" class="pf-c-form__group-label"></div>
<label class="pf-c-switch" for="${this.#fieldID}">
<input
id="${this.#fieldID}"

View File

@@ -8,26 +8,26 @@ import { ifDefined } from "lit/directives/if-defined.js";
@customElement("ak-text-input")
export class AkTextInput extends HorizontalLightComponent<string> {
@property({ type: String, reflect: true })
public value = "";
value = "";
@property({ type: String })
public autocomplete?: AutoFill;
autocomplete?: string;
@property({ type: String })
public placeholder?: string;
placeholder?: string;
#inputListener(ev: InputEvent) {
this.value = (ev.target as HTMLInputElement).value;
}
renderControl() {
const setValue = (ev: InputEvent) => {
this.value = (ev.target as HTMLInputElement).value;
};
public override renderControl() {
const code = this.inputHint === "code";
return html` <input
type="text"
role="textbox"
id=${ifDefined(this.fieldID)}
@input=${this.#inputListener}
@input=${setValue}
value=${ifDefined(this.value)}
class="${classMap({
"pf-c-form-control": true,

View File

@@ -9,18 +9,15 @@ export class AkTextareaInput extends HorizontalLightComponent<string> {
@property({ type: String, reflect: true })
public value = "";
#inputListener = (ev: InputEvent) => {
this.value = (ev.target as HTMLInputElement).value;
};
public override renderControl() {
const code = this.inputHint === "code";
const setValue = (ev: InputEvent) => {
this.value = (ev.target as HTMLInputElement).value;
};
// Prevent the leading spaces added by Prettier's whitespace algo
// prettier-ignore
return html`<textarea
id=${ifDefined(this.fieldID)}
@input=${this.#inputListener}
@input=${setValue}
class="pf-c-form-control"
?required=${this.required}
name=${this.name}

View File

@@ -35,7 +35,7 @@ export class AkToggleGroup extends CustomEmitterElement(AKElement) {
`,
];
/**
/*
* The value (causes highlighting, value is returned)
*
* @attr

View File

@@ -10,8 +10,8 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
export interface VisibilityToggleProps {
open: boolean;
disabled: boolean;
revealContentLabel: string;
hideContentLabel: string;
showMessage: string;
hideMessage: string;
}
/**
@@ -48,19 +48,19 @@ export class VisibilityToggle extends AKElement implements VisibilityToggleProps
* @attribute
*/
@property({ type: String, attribute: "show-message" })
revealContentLabel = msg("Show field content");
showMessage = msg("Show field content");
/**
* @property
* @attribute
*/
@property({ type: String, attribute: "hide-message" })
hideContentLabel = msg("Hide field content");
hideMessage = msg("Hide field content");
render() {
const [label, icon] = this.open
? [this.hideContentLabel, "fa-eye"]
: [this.revealContentLabel, "fa-eye-slash"];
? [this.hideMessage, "fa-eye"]
: [this.showMessage, "fa-eye-slash"];
const onClick = (ev: PointerEvent) => {
ev.stopPropagation();

View File

@@ -49,11 +49,11 @@ A text-input field with a visibility control, so you can show/hide sensitive fie
options: ["text", "code"],
description: "Input type hint for styling and behavior",
},
revealContentLabel: {
showMessage: {
control: "text",
description: "Custom message for show action",
},
hideContentLabel: {
hideMessage: {
control: "text",
description: "Custom message for hide action",
},
@@ -78,8 +78,8 @@ const Template: Story = {
placeholder=${ifDefined(args.placeholder)}
?required=${args.required}
input-hint=${ifDefined(args.inputHint)}
show-message=${ifDefined(args.revealContentLabel)}
hide-message=${ifDefined(args.hideContentLabel)}
show-message=${ifDefined(args.showMessage)}
hide-message=${ifDefined(args.hideMessage)}
></ak-hidden-text-input>
`,
};

View File

@@ -52,11 +52,11 @@ A textarea input field with a visibility control, so you can show/hide sensitive
options: ["text", "code"],
description: "Input type hint for styling and behavior",
},
revealContentLabel: {
showMessage: {
control: "text",
description: "Custom message for show action",
},
hideContentLabel: {
hideMessage: {
control: "text",
description: "Custom message for hide action",
},
@@ -104,8 +104,8 @@ const Template: Story = {
wrap=${ifDefined(args.wrap)}
?required=${args.required}
input-hint=${ifDefined(args.inputHint)}
show-message=${ifDefined(args.revealContentLabel)}
hide-message=${ifDefined(args.hideContentLabel)}
show-message=${ifDefined(args.showMessage)}
hide-message=${ifDefined(args.hideMessage)}
></ak-hidden-textarea-input>
`,
};
@@ -134,8 +134,8 @@ kPFn6jeMHyiq0Pqnf82T6M2EDuneMLzAgMBAAE=
inputHint: "code",
rows: 15,
resize: "vertical",
revealContentLabel: "Show certificate content",
hideContentLabel: "Hide certificate content",
showMessage: "Show certificate content",
hideMessage: "Hide certificate content",
autocomplete: "off",
},
};

View File

@@ -18,7 +18,7 @@ const metadata: Meta<VisibilityToggleProps> = {
# Visibility Toggle Component
A straightforward two-state iconic button for toggling the visibility of sensitive content such as passwords, private keys, or other secret information.
- Use for sensitive content that users might want to temporarily reveal
- There are default hide/show messages for screen readers, but they can be overridden
- Clients always handle the state
@@ -33,12 +33,12 @@ A straightforward two-state iconic button for toggling the visibility of sensiti
control: "boolean",
description: "Whether the toggle is in the 'show' state (true) or 'hide' state (false)",
},
revealContentLabel: {
showMessage: {
control: "text",
description:
'Message for screen readers when in hide state (default: "Show field content")',
},
hideContentLabel: {
hideMessage: {
control: "text",
description:
'Message for screen readers when in show state (default: "Hide field content")',
@@ -57,14 +57,14 @@ type Story = StoryObj<VisibilityToggle>;
const Template: Story = {
args: {
open: false,
revealContentLabel: "Show field content",
hideContentLabel: "Hide field content",
showMessage: "Show field content",
hideMessage: "Hide field content",
},
render: (args) => html`
<ak-visibility-toggle
?open=${args.open}
show-message=${ifDefined(args.revealContentLabel)}
hide-message=${ifDefined(args.hideContentLabel)}
show-message=${ifDefined(args.showMessage)}
hide-message=${ifDefined(args.hideMessage)}
@click=${(e: Event) => {
const target = e.target as VisibilityToggle;
target.open = !target.open;
@@ -78,8 +78,8 @@ const Template: Story = {
// Password field integration example
export const PasswordFieldExample: Story = {
args: {
revealContentLabel: "Reveal password",
hideContentLabel: "Conceal password",
showMessage: "Reveal password",
hideMessage: "Conceal password",
},
render: () => {
let isVisible = false;

View File

@@ -28,6 +28,6 @@ export abstract class Interface extends AKElement {
public connectedCallback(): void {
super.connectedCallback();
this.dataset.testId = "interface-root";
this.dataset.akInterfaceRoot = this.tagName.toLowerCase();
}
}

View File

@@ -103,7 +103,7 @@ type ContentValue = SlottedTemplateResult | undefined;
*/
export function akLoadingOverlay(
properties: ILoadingOverlay = {},
content: string | ILoadingOverlayContent = {},
content: ILoadingOverlayContent = {},
) {
// `heading` here is an Object.key of ILoadingOverlayContent, not the obsolete
// slot-name.

View File

@@ -46,7 +46,7 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
/* The array of key/value pairs this pane is currently showing */
@property({ type: Array })
public readonly options?: DualSelectPair[];
readonly options: DualSelectPair[] = [];
/**
* A set (set being easy for lookups) of keys with all the pairs selected,
@@ -54,7 +54,7 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
* can be marked and their clicks ignored.
*/
@property({ type: Object })
public readonly selected: Set<string> = new Set();
readonly selected: Set<string> = new Set();
//#endregion
@@ -75,17 +75,11 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
//#region Refs
#listRef = createRef<HTMLDivElement>();
#scrollAnimationFrame = -1;
#scrollIntoView = (): void => {
this.#listRef.value?.scrollTo(0, 0);
};
protected listRef = createRef<HTMLDivElement>();
//#region Lifecycle
public overrideconnectedCallback() {
connectedCallback() {
super.connectedCallback();
for (const [attr, value] of hostAttributes) {
@@ -95,11 +89,9 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
}
}
protected override updated(changed: PropertyValues<this>) {
if (changed.has("options") && this.options?.length) {
cancelAnimationFrame(this.#scrollAnimationFrame);
this.#scrollAnimationFrame = requestAnimationFrame(this.#scrollIntoView);
protected updated(changed: PropertyValues<this>) {
if (changed.has("options")) {
this.listRef.value?.scrollTo(0, 0);
}
}
@@ -126,9 +118,10 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
this.toMove.add(key);
}
const moved = [...this.toMove].sort();
this.dispatchCustomEvent(DualSelectEventType.MoveChanged, moved);
this.dispatchCustomEvent(
DualSelectEventType.MoveChanged,
Array.from(this.toMove.values()).sort(),
);
this.dispatchCustomEvent(DualSelectEventType.Move);
@@ -152,7 +145,7 @@ export class AkDualSelectAvailablePane extends CustomEmitterElement<DualSelectEv
render() {
return html`
<div ${ref(this.#listRef)} class="pf-c-dual-list-selector__menu">
<div ${ref(this.listRef)} class="pf-c-dual-list-selector__menu">
<ul class="pf-c-dual-list-selector__list">
${map(this.options, ([key, label]) => {
const selected = classMap({

View File

@@ -100,11 +100,9 @@ export const globalVariables = css`
--pf-c-dual-list-selector__list-item-row--BackgroundColor: var(
--ak-dark-background-light-ish
);
--pf-c-dual-list-selector__list-item-row--focus-within--BackgroundColor: var(
--ak-dark-background-darker
--pf-c-dual-list-selector__list-item-row--hover--BackgroundColor: var(
--ak-dark-background-lighter;
);
--pf-c-dual-list-selector__list-item-row--hover--BackgroundColor: var(
--pf-global--BackgroundColor--400
);

View File

@@ -1,6 +1,7 @@
import { groupOptions, isVisibleInScrollRegion } from "./utils.js";
import { AKElement } from "#elements/Base";
import { bound } from "#elements/decorators/bound";
import type { GroupedOptions, SelectGroup, SelectOption, SelectOptions } from "#elements/types";
import { randomId } from "#elements/utils/randomId";
@@ -15,7 +16,7 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
export interface IListSelect {
options: SelectOptions;
value?: string | null;
value?: string;
emptyOption?: string;
}
@@ -67,23 +68,21 @@ export class ListSelect extends AKElement implements IListSelect {
`,
];
//#region Properties
/**
* See the search options type, described in the `./types` file, for the relevant types.
*
* @prop
*/
@property({ type: Array, attribute: false })
public set options(options: SelectOptions) {
this.#options = groupOptions(options);
set options(options: SelectOptions) {
this._options = groupOptions(options);
}
public get options() {
return this.#options;
get options() {
return this._options;
}
#options!: GroupedOptions;
_options!: GroupedOptions;
/**
* The current value of the menu.
@@ -91,7 +90,7 @@ export class ListSelect extends AKElement implements IListSelect {
* @prop
*/
@property({ type: String, reflect: true })
public value?: string | null = null;
value?: string;
/**
* The string representation that means an empty option. If not present, no empty option is
@@ -100,57 +99,36 @@ export class ListSelect extends AKElement implements IListSelect {
* @prop
*/
@property()
public emptyOption?: string;
emptyOption?: string;
// We have two different states that we're tracking in this component: the `value`, which is the
// element that is currently selected according to the client, and the `index`, which is the
// element that is being tracked for keyboard interaction. On a click, the index points to the
// value element; on Keyup.Enter, the value becomes whatever the index points to.
// value element; on Keydown.Enter, the value becomes whatever the index points to.
@state()
protected indexOfFocusedItem = 0;
indexOfFocusedItem = 0;
@query("#ak-list-select-list")
protected ul!: HTMLUListElement;
//#endregion
ul!: HTMLUListElement;
get json(): string {
return this.value ?? "";
}
//#region Lifecycle
public constructor() {
super();
this.addEventListener("focus", this.onFocus);
this.addEventListener("blur", this.onBlur);
}
public override connectedCallback() {
super.connectedCallback();
this.addEventListener("focus", this.#focusListener);
this.addEventListener("blur", this.#blurListener);
this.setAttribute("data-ouia-component-type", "ak-menu-select");
this.setAttribute("data-ouia-component-id", this.getAttribute("id") || randomId());
this.setIndexOfFocusedItemFromValue();
this.highlightFocusedItem();
}
public override disconnectedCallback() {
super.disconnectedCallback();
this.removeEventListener("focus", this.#focusListener);
this.removeEventListener("blur", this.#blurListener);
}
public override performUpdate() {
this.removeAttribute("data-ouia-component-safe");
super.performUpdate();
}
public override updated(changed: PropertyValueMap<this>) {
super.updated(changed);
this.setAttribute("data-ouia-component-safe", "true");
}
//#endregion
public get hasFocus() {
return this.renderRoot.contains(document.activeElement) || document.activeElement === this;
}
@@ -193,29 +171,30 @@ export class ListSelect extends AKElement implements IListSelect {
currentElement.scrollIntoView({ block: "center", behavior: "smooth" });
}
//#region Event Listeners
#focusListener = () => {
@bound
onFocus() {
// Allow the event to propagate.
this.currentElement?.focus();
this.addEventListener("keyup", this.#delegateKey);
};
this.addEventListener("keydown", this.onKeydown);
}
#blurListener = () => {
@bound
onBlur() {
// Allow the event to propagate.
this.removeEventListener("keyup", this.#delegateKey);
this.removeEventListener("keydown", this.onKeydown);
this.indexOfFocusedItem = 0;
};
}
#clickListener = (value: string | null) => {
@bound
onClick(value: string | undefined) {
// let the click through, but include the change event.
this.value = value;
this.setIndexOfFocusedItemFromValue();
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
};
this.dispatchEvent(new Event("change", { bubbles: true, composed: true })); // prettier-ignore
}
#delegateKey = (event: KeyboardEvent) => {
@bound
onKeydown(event: KeyboardEvent) {
const key = event.key;
const lastItem = this.displayedElements.length - 1;
const current = this.indexOfFocusedItem;
@@ -229,9 +208,8 @@ export class ListSelect extends AKElement implements IListSelect {
const setValueAndDispatch = () => {
event.preventDefault();
this.value = this.currentElement?.getAttribute("value");
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
this.value = this.currentElement?.getAttribute("value") ?? undefined;
this.dispatchEvent(new Event("change", { bubbles: true, composed: true })); // prettier-ignore
};
const pageBy = (direction: number) => {
@@ -251,9 +229,17 @@ export class ListSelect extends AKElement implements IListSelect {
.with({ key: "End" }, () => updateIndex(lastItem))
.with({ key: " " }, () => setValueAndDispatch())
.with({ key: "Enter" }, () => setValueAndDispatch());
};
}
//#region Render
public override performUpdate() {
this.removeAttribute("data-ouia-component-safe");
super.performUpdate();
}
public override updated(changed: PropertyValueMap<this>) {
super.updated(changed);
this.setAttribute("data-ouia-component-safe", "true");
}
private renderEmptyMenuItem() {
return html`<li role="option" class="ak-select-item" part="ak-list-select-option">
@@ -261,7 +247,7 @@ export class ListSelect extends AKElement implements IListSelect {
class="pf-c-dropdown__menu-item"
role="option"
tabindex="0"
@click=${() => this.#clickListener(null)}
@click=${() => this.onClick(undefined)}
part="ak-list-select-button"
>
${this.emptyOption}
@@ -282,7 +268,7 @@ export class ListSelect extends AKElement implements IListSelect {
class="pf-c-dropdown__menu-item pf-m-description"
value="${value}"
tabindex="0"
@click=${() => this.#clickListener(value)}
@click=${() => this.onClick(value)}
part="ak-list-select-button"
>
<div class="pf-c-dropdown__menu-item-main" part="ak-list-select-label">
@@ -330,15 +316,13 @@ export class ListSelect extends AKElement implements IListSelect {
tabindex="0"
part="ak-list-select"
>
${this.emptyOption ? this.renderEmptyMenuItem() : nothing}
${this.#options.grouped
? this.renderMenuGroups(this.#options.options)
: this.renderMenuItems(this.#options.options)}
${this.emptyOption === undefined ? nothing : this.renderEmptyMenuItem()}
${this._options.grouped
? this.renderMenuGroups(this._options.options)
: this.renderMenuItems(this._options.options)}
</ul>
</div> `;
}
//#endregion
}
declare global {

View File

@@ -51,13 +51,13 @@ export class ModalOrchestrationController implements ReactiveController {
#knownModals: ModalElement[] = [];
public hostConnected() {
window.addEventListener("keyup", this.#keyupListener);
window.addEventListener("keyup", this.handleKeyup);
window.addEventListener("ak-modal-show", this.#addModal);
window.addEventListener("ak-modal-hide", this.closeModal);
}
public hostDisconnected() {
window.removeEventListener("keyup", this.#keyupListener);
window.removeEventListener("keyup", this.handleKeyup);
window.removeEventListener("ak-modal-show", this.#addModal);
window.removeEventListener("ak-modal-hide", this.closeModal);
}
@@ -108,16 +108,8 @@ export class ModalOrchestrationController implements ReactiveController {
this.#knownModals = knownModals;
};
#keyupListener = ({ key, defaultPrevented }: KeyboardEvent) => {
handleKeyup = ({ key }: KeyboardEvent) => {
// The latter handles Firefox 37 and earlier.
if (key !== "Escape" && key !== "Esc") {
return;
}
// Allow an event listener within the modal to prevent
// our default behavior of closing the modal.
if (defaultPrevented) return;
if (key === "Escape" || key === "Esc") {
this.#removeTopmostModal();
}

View File

@@ -0,0 +1,70 @@
import { AKElement } from "#elements/Base";
import { ErrorDetail } from "@goauthentik/api";
import { CSSResult, html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
/**
* This is used in two places outside of Flow, and in both cases is used primarily to
* display content, not take input. It displays the TOTP QR code, and the static
* recovery tokens. But it's used a lot in Flow.
*/
@customElement("ak-form-element")
export class FormElement extends AKElement {
static styles: CSSResult[] = [PFBase, PFForm, PFFormControl];
@property()
label?: string;
@property({ type: Boolean })
required = false;
@property({ attribute: false })
set errors(value: ErrorDetail[] | undefined) {
this._errors = value;
const hasError = (value || []).length > 0;
this.querySelectorAll("input").forEach((input) => {
input.setAttribute("aria-invalid", hasError.toString());
});
this.requestUpdate();
}
_errors?: ErrorDetail[];
updated(): void {
this.querySelectorAll<HTMLInputElement>("input[autofocus]").forEach((input) => {
input.focus();
});
}
render(): TemplateResult {
return html`<div class="pf-c-form__group">
<label class="pf-c-form__label">
<span class="pf-c-form__label-text">${this.label}</span>
${this.required
? html`<span class="pf-c-form__label-required" aria-hidden="true">*</span>`
: html``}
</label>
<slot></slot>
${(this._errors || []).map((error) => {
return html`<p class="pf-c-form__helper-text pf-m-error">
<span class="pf-c-form__helper-text-icon">
<i class="fas fa-exclamation-circle" aria-hidden="true"></i> </span
>${error.string}
</p>`;
})}
</div>`;
}
}
declare global {
interface HTMLElementTagNameMap {
"ak-form-element": FormElement;
}
}

View File

@@ -1,7 +1,7 @@
import { AKElement } from "#elements/Base";
import { msg } from "@lit/localize";
import { css, CSSResult, html, PropertyValues, TemplateResult } from "lit";
import { css, CSSResult, html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { createRef, ref } from "lit/directives/ref.js";
@@ -20,6 +20,15 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
*/
@customElement("ak-form-group")
export class AKFormGroup extends AKElement {
@property({ type: Boolean, reflect: true })
public open = false;
@property({ type: String, reflect: true })
public label = msg("Details");
@property({ type: String, reflect: true })
public description?: string;
static styles: CSSResult[] = [
PFBase,
PFForm,
@@ -37,6 +46,27 @@ export class AKFormGroup extends AKElement {
}
details {
&::details-content {
height: 0;
overflow: clip;
transition-behavior: normal, allow-discrete;
transition-duration: var(--pf-global--TransitionDuration);
transition-timing-function: var(--pf-global--TimingFunction);
transition-property: height, content-visibility;
@media (prefers-reduced-motion) {
transition-duration: 0;
}
}
@supports (interpolate-size: allow-keywords) {
interpolate-size: allow-keywords;
&[open]::details-content {
height: auto;
}
}
&::details-content {
padding-inline-start: var(
--pf-c-form__field-group--GridTemplateColumns--toggle
@@ -72,39 +102,12 @@ export class AKFormGroup extends AKElement {
`,
];
//region Properties
formRef = createRef<HTMLFormElement>();
@property({ type: Boolean, reflect: true })
public open = false;
scrollAnimationFrame = -1;
@property({ type: String, reflect: true })
public label = msg("Details");
@property({ type: String, reflect: true })
public description?: string;
//#endregion
//#region Lifecycle
public override updated(changedProperties: PropertyValues<this>): void {
const previousOpen = changedProperties.get("open");
if (typeof previousOpen !== "boolean") return;
if (this.open && this.open !== previousOpen) {
cancelAnimationFrame(this.#scrollAnimationFrame);
this.#scrollAnimationFrame = requestAnimationFrame(this.#scrollIntoView);
}
}
#detailsRef = createRef<HTMLDetailsElement>();
#scrollAnimationFrame = -1;
#scrollIntoView = (): void => {
this.#detailsRef.value?.scrollIntoView({
scrollIntoView = (): void => {
this.formRef.value?.scrollIntoView({
behavior: "smooth",
});
};
@@ -114,16 +117,19 @@ export class AKFormGroup extends AKElement {
*/
public toggle = (event: Event): void => {
event.preventDefault();
cancelAnimationFrame(this.scrollAnimationFrame);
this.open = !this.open;
};
//#region Render
if (this.open) {
this.scrollAnimationFrame = requestAnimationFrame(this.scrollIntoView);
}
};
public render(): TemplateResult {
return html`
<details
${ref(this.#detailsRef)}
${ref(this.formRef)}
?open=${this.open}
?aria-expanded="${this.open}"
role="group"
@@ -161,8 +167,6 @@ export class AKFormGroup extends AKElement {
</details>
`;
}
//#endregion
}
declare global {

View File

@@ -1,13 +1,10 @@
import { isControlElement } from "#elements/AkControlElement";
import { AKElement } from "#elements/Base";
import { AKFormGroup } from "#elements/forms/FormGroup";
import { isNameableElement } from "#elements/utils/inputs";
import { AKFormErrors, ErrorProp } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { css, CSSResult, html, nothing, TemplateResult } from "lit";
import { msg, str } from "@lit/localize";
import { css, CSSResult, html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
@@ -33,6 +30,22 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
* being very few unique uses.
*/
const isAkControl = (el: unknown): boolean =>
el instanceof HTMLElement &&
"dataset" in el &&
el.dataset instanceof DOMStringMap &&
"akControl" in el.dataset;
const nameables = new Set([
"input",
"textarea",
"select",
"ak-codemirror",
"ak-chip-group",
"ak-search-select",
"ak-radio",
]);
@customElement("ak-form-element-horizontal")
export class HorizontalFormElement extends AKElement {
static styles: CSSResult[] = [
@@ -46,40 +59,41 @@ export class HorizontalFormElement extends AKElement {
var(--pf-c-form--m-horizontal__group-label--md--GridColumnWidth)
var(--pf-c-form--m-horizontal__group-control--md--GridColumnWidth);
}
.pf-c-form__group-label {
padding-top: var(--pf-c-form--m-horizontal__group-label--md--PaddingTop);
}
.pf-c-form__label[aria-required] .pf-c-form__label-text::after {
content: "*";
user-select: none;
margin-left: var(--pf-c-form__label-required--MarginLeft);
font-size: var(--pf-c-form__label-required--FontSize);
color: var(--pf-c-form__label-required--Color);
}
`,
];
//#region Properties
/**
* A unique ID to associate with the input and label.
*/
@property({ type: String, reflect: false })
public fieldID?: string;
/**
* The label for the input control
* @property
* @attribute
* @deprecated Labels cannot associate with inputs across DOM roots. Use the slotted `label` element instead.
*/
@property({ type: String })
public label?: string;
public label = "";
@property({ type: Boolean })
public required?: boolean;
public required = false;
@property({ attribute: false })
public errorMessages?: ErrorProp[];
public errorMessages: string[] | string[][] = [];
#invalid = false;
_invalid = false;
/* If this property changes, we want to make sure the parent control is "opened" so
* that users can see the change.[1]
*/
@property({ type: Boolean })
set invalid(v: boolean) {
this.#invalid = v;
this._invalid = v;
// check if we're in a form group, and expand that form group
const parent = this.parentElement?.parentElement;
@@ -88,64 +102,80 @@ export class HorizontalFormElement extends AKElement {
}
}
get invalid(): boolean {
return this.#invalid;
return this._invalid;
}
@property({ type: String })
public name?: string;
public name = "";
//#endregion
@property({
type: String,
attribute: "flow-direction",
})
public flowDirection: "row" | "column" = "column";
//#region Lifecycle
public override firstUpdated(): void {
firstUpdated(): void {
this.updated();
}
/**
* Ensure that all inputs have a name attribute.
*
* TODO: Swap with `HTMLElement.prototype.attachInternals`.
*/
public override updated(): void {
// If we don't have a name, we can't do anything.
if (!this.name) return;
updated(): void {
this.querySelectorAll<HTMLInputElement>("input[autofocus]").forEach((input) => {
input.focus();
});
this.querySelectorAll("*").forEach((input) => {
if (isAkControl(input) && !input.getAttribute("name")) {
input.setAttribute("name", this.name);
return;
}
for (const element of this.querySelectorAll("*")) {
// Is this element capable of being named?
if (!isControlElement(element) && !isNameableElement(element)) continue;
// And does the element already match the name?
if (element.getAttribute("name") === this.name) continue;
element.setAttribute("name", this.name);
}
if (nameables.has(input.tagName.toLowerCase())) {
input.setAttribute("name", this.name);
} else {
return;
}
});
}
//#endregion
//#region Rendering
render(): TemplateResult {
this.updated();
return html`<div class="pf-c-form__group" role="group">
${this.label
? html`<div class="pf-c-form__group-label">
${AKLabel({ htmlFor: this.fieldID, required: this.required }, this.label)}
</div>`
: nothing}
<slot name="label"></slot>
return html`<div
class="pf-c-form__group"
role="group"
aria-label="${this.label}"
data-flow-direction="${this.flowDirection}"
>
<div class="pf-c-form__group-label">
<label
id="group-label"
class="pf-c-form__label"
?aria-required=${this.required}
for="${ifDefined(this.fieldID)}"
>
<span class="pf-c-form__label-text">${this.label}</span>
</label>
</div>
<div class="pf-c-form__group-control">
<slot class="pf-c-form__horizontal-group"></slot>
<div class="pf-c-form__horizontal-group">
${AKFormErrors({ errors: this.errorMessages })}
${this.errorMessages.map((message) => {
if (message instanceof Object) {
return html`${Object.entries(message).map(([field, errMsg]) => {
return html`<p
class="pf-c-form__helper-text pf-m-error"
aria-live="polite"
>
${msg(str`${field}: ${errMsg}`)}
</p>`;
})}`;
}
return html`<p class="pf-c-form__helper-text pf-m-error" aria-live="polite">
${message}
</p>`;
})}
</div>
</div>
</div>`;
}
//#endregion
}
declare global {

View File

@@ -22,140 +22,82 @@ import PFBase from "@patternfly/patternfly/patternfly-base.css";
type Group<T> = [string, T[]];
export interface ISearchSelectBase<T> {
blankable?: boolean;
blankable: boolean;
query?: string;
objects?: T[];
selectedObject: T | null;
selectedObject?: T;
name?: string;
placeholder?: string;
placeholder: string;
emptyOption: string;
}
export abstract class SearchSelectBase<T>
extends AkControlElement<string>
implements ISearchSelectBase<T>
{
export class SearchSelectBase<T> extends AkControlElement<string> implements ISearchSelectBase<T> {
static styles = [PFBase];
//#region Properties
// A function which takes the query state object (accepting that it may be empty) and returns a
// new collection of objects.
fetchObjects!: (query?: string) => Promise<T[]>;
/**
* A function which takes the query state object (accepting that it may be empty)
* and returns a
* new collection of objects.
*/
public abstract fetchObjects: (query?: string) => Promise<T[]>;
// A function passed to this object that extracts a string representation of items of the
// collection under search.
renderElement!: (element: T) => string;
/**
* A function passed to this object that extracts a string representation of items of the
* collection under search.
*/
public abstract renderElement: (element: T) => string;
// A function passed to this object that extracts an HTML representation of additional
// information for items of the collection under search.
renderDescription?: (element: T) => string | TemplateResult;
/**
* A function passed to this object that extracts an HTML representation of additional
* information for items of the collection under search.
*/
public abstract renderDescription?: (element: T) => string | TemplateResult;
// A function which returns the currently selected object's primary key, used for serialization
// into forms.
value!: (element: T | undefined) => string;
/**
* A function which returns the currently selected object's primary key, used for serialization
* into forms.
*/
public abstract value: (element: T | null) => string;
// A function passed to this object that determines an object in the collection under search
// should be automatically selected. Only used when the search itself is responsible for
// fetching the data; sets an initial default value.
selected?: (element: T, elements: T[]) => boolean;
/**
* A function passed to this object that determines an object in the collection under search
* should be automatically selected. Only used when the search itself is responsible for
* fetching the data; sets an initial default value.
*/
public abstract selected?: (element: T, elements: T[]) => boolean;
/**
* A function passed to this object (or using the default below) that groups objects in the
* collection under search into categories.
*/
public groupBy: (items: T[]) => [string, T[]][] = (items) => {
return groupBy(items, () => "");
// A function passed to this object (or using the default below) that groups objects in the
// collection under search into categories.
groupBy: (items: T[]) => [string, T[]][] = (items: T[]): [string, T[]][] => {
return groupBy(items, () => {
return "";
});
};
/**
* Whether or not the dropdown component can be left blank
* @property
* @attr
*/
// Whether or not the dropdown component can be left blank
@property({ type: Boolean })
public blankable?: boolean;
blankable = false;
/**
* An initial string to filter the search contents,
* and the value of the input which further serves to restrict the search.
* @property
*/
@property({ type: String })
public query?: string;
// An initial string to filter the search contents, and the value of the input which further
// serves to restrict the search
@property()
query?: string;
// The objects currently available under search
@property({ attribute: false })
public objects?: T[];
objects?: T[];
/**
* The currently selected object.
* @property
*/
// The currently selected object
@property({ attribute: false })
public selectedObject: T | null = null;
selectedObject?: T;
/**
* Used to inform the form of the name of the object
* @property
*/
// Used to inform the form of the name of the object
@property()
public name?: string;
name?: string;
/**
* A unique ID to associate with the input and label.
* @property
*/
@property({ type: String, reflect: false })
protected fieldID?: string;
/**
* Used to inform the form of the input label.
* @property
*/
// The textual placeholder for the search's <input> object, if currently empty. Used as the
// native <input> object's `placeholder` field.
@property()
public label?: string;
placeholder: string = msg("Select an object.");
/**
* The textual placeholder for the search's <input> object, if currently empty.
*
* Used as the native <input> object's `placeholder` field.
* @property
* @attr
*/
@property({ type: String })
public placeholder?: string = msg("Select an object.");
// A textual string representing "The user has affirmed they want to leave the selection blank."
// Only used if `blankable` above is true.
@property()
emptyOption = "---------";
/**
* A textual string representing "The user has affirmed they want to leave the selection blank."
* Only used if `blankable` above is true.
*
* @property
*/
@property({ type: String })
public emptyOption = "---------";
//#endregion
//#region State
#loading = false;
isFetchingData = false;
@state()
protected error?: APIError;
//#endregion
error?: APIError;
public toForm(): string {
if (!this.objects) {
@@ -168,7 +110,7 @@ export abstract class SearchSelectBase<T>
return this.toForm();
}
protected dispatchChangeEvent(value: T | null) {
protected dispatchChangeEvent(value: T | undefined) {
this.dispatchEvent(
new CustomEvent("ak-change", {
composed: true,
@@ -179,27 +121,26 @@ export abstract class SearchSelectBase<T>
}
public async updateData() {
if (this.#loading) {
if (this.isFetchingData) {
return Promise.resolve();
}
this.#loading = true;
this.isFetchingData = true;
this.dispatchEvent(new Event("loading"));
return this.fetchObjects(this.query)
.then((nextObjects) => {
const selectedObject = nextObjects.find((obj) => this.selected?.(obj, nextObjects));
if (selectedObject) {
this.selectedObject = selectedObject;
this.dispatchChangeEvent(this.selectedObject);
}
nextObjects.forEach((obj) => {
if (this.selected && this.selected(obj, nextObjects || [])) {
this.selectedObject = obj;
this.dispatchChangeEvent(this.selectedObject);
}
});
this.objects = nextObjects;
this.#loading = false;
this.isFetchingData = false;
})
.catch(async (error: unknown) => {
this.#loading = false;
this.isFetchingData = false;
this.objects = undefined;
const parsedError = await parseAPIResponseError(error);
@@ -222,11 +163,10 @@ export abstract class SearchSelectBase<T>
this.removeEventListener(EVENT_REFRESH, this.updateData);
}
#searchListener = (event: InputEvent) => {
private onSearch(event: InputEvent) {
const value = (event.target as SearchSelectView).rawValue;
if (!value) {
this.selectedObject = null;
if (value === undefined) {
this.selectedObject = undefined;
return;
}
@@ -234,23 +174,19 @@ export abstract class SearchSelectBase<T>
this.updateData()?.then(() => {
this.dispatchChangeEvent(this.selectedObject);
});
};
}
private onSelect(event: InputEvent) {
const value = (event.target as SearchSelectView).value;
if (!value) {
this.selectedObject = null;
this.dispatchChangeEvent(null);
if (value === undefined) {
this.selectedObject = undefined;
this.dispatchChangeEvent(undefined);
return;
}
const selected = this.objects?.find((obj) => this.value(obj) === value) || null;
const selected = (this.objects ?? []).find((obj) => `${this.value(obj)}` === value);
if (!selected) {
console.warn(`ak-search-select: No corresponding object found for value (${value}`);
}
this.selectedObject = selected;
this.dispatchChangeEvent(this.selectedObject);
}
@@ -319,26 +255,24 @@ export abstract class SearchSelectBase<T>
return html`<ak-search-select-view
managed
.fieldID=${this.fieldID}
.options=${options}
value=${ifDefined(value)}
?blankable=${this.blankable}
label=${ifDefined(this.label)}
name=${ifDefined(this.name)}
placeholder=${this.placeholder}
emptyOption=${ifDefined(this.blankable ? this.emptyOption : undefined)}
@input=${this.#searchListener}
@input=${this.onSearch}
@change=${this.onSelect}
></ak-search-select-view> `;
}
public override updated(changed: PropertyValues<this>) {
if (!this.#loading && changed.has("objects")) {
if (!this.isFetchingData && changed.has("objects")) {
this.dispatchEvent(new Event("ready"));
}
// It is not safe for automated tests to interact with this component while it is fetching
// data.
if (!this.#loading) {
if (!this.isFetchingData) {
this.setAttribute("data-ouia-component-safe", "true");
}
}

View File

@@ -7,7 +7,7 @@ export interface ISearchSelectApi<T> {
fetchObjects: (query?: string) => Promise<T[]>;
renderElement: (element: T) => string;
renderDescription?: (element: T) => string | TemplateResult;
value: (element: T | null) => string;
value: (element: T | undefined) => string;
selected?: (element: T, elements: T[]) => boolean;
groupBy?: (items: T[]) => [string, T[]][];
}
@@ -47,26 +47,18 @@ export interface ISearchSelectEz<T> extends ISearchSelectBase<T> {
export class SearchSelectEz<T> extends SearchSelectBase<T> implements ISearchSelectEz<T> {
static styles = [...SearchSelectBase.styles];
public fetchObjects!: (query?: string) => Promise<T[]>;
public renderElement!: (element: T) => string;
public renderDescription?: ((element: T) => string | TemplateResult) | undefined;
public value!: (element: T | null) => string;
public selected?: ((element: T, elements: T[]) => boolean) | undefined;
@property({ type: Object, attribute: false })
public config!: ISearchSelectApi<T>;
config!: ISearchSelectApi<T>;
public override connectedCallback() {
connectedCallback() {
this.fetchObjects = this.config.fetchObjects;
this.renderElement = this.config.renderElement;
this.renderDescription = this.config.renderDescription;
this.value = this.config.value;
this.selected = this.config.selected;
if (this.config.groupBy) {
if (this.config.groupBy !== undefined) {
this.groupBy = this.config.groupBy;
}
super.connectedCallback();
}
}

View File

@@ -5,11 +5,12 @@ import { findFlatOptions, findOptionsSubset, groupOptions, optionsToFlat } from
import { ListSelect } from "#elements/ak-list-select/ak-list-select";
import { AKElement } from "#elements/Base";
import { bound } from "#elements/decorators/bound";
import type { GroupedOptions, SelectOption, SelectOptions } from "#elements/types";
import { randomId } from "#elements/utils/randomId";
import { msg } from "@lit/localize";
import { CSSResult, html, nothing, PropertyValues } from "lit";
import { html, nothing, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { createRef, ref, Ref } from "lit/directives/ref.js";
@@ -69,9 +70,7 @@ export interface ISearchSelectView {
*/
@customElement("ak-search-select-view")
export class SearchSelectView extends AKElement implements ISearchSelectView {
static styles: CSSResult[] = [PFBase, PFForm, PFFormControl, PFSelect];
//#region Properties
static styles = [PFBase, PFForm, PFFormControl, PFSelect];
/**
* The options collection. The simplest variant is just [key, label, optional<description>]. See
@@ -80,16 +79,16 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @prop
*/
@property({ type: Array, attribute: false })
public set options(options: SelectOptions) {
this.#options = groupOptions(options);
this.#flatOptions = optionsToFlat(this.#options);
set options(options: SelectOptions) {
this._options = groupOptions(options);
this.flatOptions = optionsToFlat(this._options);
}
public get options() {
return this.#options;
get options() {
return this._options;
}
#options!: GroupedOptions;
_options!: GroupedOptions;
/**
* The current value. Must be one of the keys in the options group above.
@@ -97,7 +96,7 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @prop
*/
@property({ type: String, reflect: true })
public value?: string;
value?: string;
/**
* Whether or not the dropdown is open
@@ -105,7 +104,7 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @attr
*/
@property({ type: Boolean, reflect: true })
public open = false;
open = false;
/**
* If set to true, this object MAY return undefined in no value is passed in and none is set
@@ -114,7 +113,7 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @attr
*/
@property({ type: Boolean })
public blankable = false;
blankable = false;
/**
* If not managed, make the matcher case-sensitive during interaction. If managed,
@@ -123,23 +122,15 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @attr
*/
@property({ type: Boolean, attribute: "case-sensitive" })
public caseSensitive = false;
caseSensitive = false;
/**
* The name of the input, for forms.
* The name of the input, for forms
*
* @attr
*/
@property({ type: String })
public name?: string;
/**
* The label of the input, for forms.
*
* @attr
*/
@property({ type: String })
public label?: string;
name?: string;
/**
* The textual placeholder for the search's <input> object, if currently empty. Used as the
@@ -148,14 +139,7 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @attr
*/
@property({ type: String })
public placeholder: string = msg("Select an object.");
/**
* A unique ID to associate with the input and label.
* @property
*/
@property({ type: String, reflect: false })
protected fieldID?: string;
placeholder: string = msg("Select an object.");
/**
* If true, the component only sends an input message up to a parent component. If false, the
@@ -165,7 +149,7 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
*@attr
*/
@property({ type: Boolean })
public managed = false;
managed = false;
/**
* A textual string representing "The user has affirmed they want to leave the selection blank."
@@ -174,50 +158,36 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
* @attr
*/
@property()
public emptyOption = "---------";
emptyOption = "---------";
//#endregion
// Handle the behavior of the drop-down when the :host scrolls off the page.
scrollHandler?: () => void;
//#region State
// observer: IntersectionObserver;
@state()
protected displayValue = "";
displayValue = "";
// Tracks when the inputRef is populated, so we can safely reschedule the
// render of the dropdown with respect to it.
@state()
protected inputRefIsAvailable = false;
inputRefIsAvailable = false;
/**
* Permanent identity with the portal so focus events can be checked.
*/
#menuRef: Ref<ListSelect> = createRef();
menuRef: Ref<ListSelect> = createRef();
/**
* Permanent identify for the input object, so the floating portal can find where to anchor
* itself.
*/
#inputRef: Ref<HTMLInputElement> = createRef();
inputRef: Ref<HTMLInputElement> = createRef();
/**
* Maps a value from the portal to labels to be put into the <input> field>
* Maps a value from the portal to labels to be put into the <input> field>
*/
#flatOptions: [label: string, option: SelectOption][] = [];
//#endregion
//#region Lifecycle
public override updated() {
this.setAttribute("data-ouia-component-safe", "true");
}
public override firstUpdated() {
// Route around Lit's scheduling algorithm complaining about re-renders
window.setTimeout(() => {
this.inputRefIsAvailable = Boolean(this.#inputRef?.value);
}, 0);
}
flatOptions: [string, SelectOption][] = [];
connectedCallback() {
super.connectedCallback();
@@ -233,90 +203,73 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
// TODO
}
//#endregion
//#region Event Listeners
#clickListener = (_ev: Event) => {
@bound
onClick(_ev: Event) {
this.open = !this.open;
this.#inputRef.value?.focus();
};
this.inputRef.value?.focus();
}
setFromMatchList(value?: string) {
if (!value) return;
const probableValue = this.#flatOptions.find(([label]) => label === this.value);
if (probableValue && this.#inputRef.value) {
this.#inputRef.value.value = probableValue[1][1];
setFromMatchList(value: string | undefined) {
if (value === undefined) {
return;
}
const probableValue = this.flatOptions.find((option) => option[0] === this.value);
if (probableValue && this.inputRef.value) {
this.inputRef.value.value = probableValue[1][1];
}
}
#searchKeyupListener = (event: KeyboardEvent) => {
if (event.key === "Escape") {
@bound
onKeydown(event: KeyboardEvent) {
if (event.code === "Escape") {
event.stopPropagation();
event.preventDefault();
this.open = false;
}
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
event.preventDefault();
this.#menuRef.value?.currentElement?.focus();
if (event.code === "ArrowDown" || event.code === "ArrowUp") {
this.open = true;
}
};
#searchKeydownListener = (event: KeyboardEvent) => {
if (!this.open) return;
switch (event.key) {
case "ArrowDown":
case "ArrowUp":
event.preventDefault();
this.setFromMatchList(this.value);
break;
case "Tab":
event.preventDefault();
this.setFromMatchList(this.value);
this.#menuRef.value?.currentElement?.focus();
if (event.code === "Tab" && this.open) {
event.preventDefault();
this.setFromMatchList(this.value);
this.menuRef.value?.currentElement?.focus();
}
};
}
#blurListener = (event: FocusEvent) => {
@bound
onListBlur(event: FocusEvent) {
// If we lost focus but the menu got it, don't do anything;
const relatedTarget = event.relatedTarget as HTMLElement | undefined;
if (
relatedTarget &&
(this.contains(relatedTarget) ||
this.renderRoot.contains(relatedTarget) ||
this.#menuRef.value?.contains(relatedTarget) ||
this.#menuRef.value?.renderRoot.contains(relatedTarget))
this.menuRef.value?.contains(relatedTarget) ||
this.menuRef.value?.renderRoot.contains(relatedTarget))
) {
return;
}
this.open = false;
if (!this.value) {
if (this.#inputRef.value) {
this.#inputRef.value.value = "";
if (this.value === undefined) {
if (this.inputRef.value) {
this.inputRef.value.value = "";
}
this.setValue(undefined);
}
};
}
setValue(newValue: string | undefined) {
this.value = newValue;
this.dispatchEvent(new Event("change", { bubbles: true, composed: true }));
this.dispatchEvent(new Event("change", { bubbles: true, composed: true })); // prettier-ignore
}
findValueForInput() {
const value = this.#inputRef.value?.value;
const value = this.inputRef.value?.value;
if (value === undefined || value.trim() === "") {
this.setValue(undefined);
return;
}
const matchesFound = findFlatOptions(this.#flatOptions, value);
const matchesFound = findFlatOptions(this.flatOptions, value);
if (matchesFound.length > 0) {
const newValue = matchesFound[0][0];
if (newValue === value) {
@@ -328,52 +281,47 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
}
}
#inputListener = (_ev: InputEvent) => {
@bound
onInput(_ev: InputEvent) {
if (!this.managed) {
this.findValueForInput();
this.requestUpdate();
}
this.open = true;
};
}
#listKeyupListener = (event: KeyboardEvent) => {
@bound
onListKeydown(event: KeyboardEvent) {
if (event.key === "Escape") {
event.preventDefault();
this.open = false;
this.#inputRef.value?.focus();
this.inputRef.value?.focus();
}
};
#listKeydownListener = (event: KeyboardEvent) => {
if (event.key === "Tab" && event.shiftKey) {
event.preventDefault();
this.#inputRef.value?.focus();
this.inputRef.value?.focus();
}
};
}
#changeListener = (event: InputEvent) => {
@bound
onListChange(event: InputEvent) {
if (!event.target) {
return;
}
const value = (event.target as HTMLInputElement).value;
if (value) {
if (value !== undefined) {
const newDisplayValue = this.findDisplayForValue(value);
if (this.#inputRef.value) {
this.#inputRef.value.value = newDisplayValue ?? "";
if (this.inputRef.value) {
this.inputRef.value.value = newDisplayValue ?? "";
}
} else if (this.#inputRef.value) {
this.#inputRef.value.value = "";
} else if (this.inputRef.value) {
this.inputRef.value.value = "";
}
this.open = false;
this.setValue(value);
};
//#endregion
}
findDisplayForValue(value: string) {
const newDisplayValue = this.#flatOptions.find((option) => option[0] === value);
const newDisplayValue = this.flatOptions.find((option) => option[0] === value);
return newDisplayValue ? newDisplayValue[1][1] : undefined;
}
@@ -392,17 +340,15 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
}
get rawValue() {
return this.#inputRef.value?.value ?? "";
return this.inputRef.value?.value ?? "";
}
get managedOptions() {
return this.managed
? this.#options
: findOptionsSubset(this.#options, this.rawValue, this.caseSensitive);
? this._options
: findOptionsSubset(this._options, this.rawValue, this.caseSensitive);
}
//#region Render
public override render() {
const emptyOption = this.blankable ? this.emptyOption : undefined;
const open = this.open;
@@ -411,22 +357,17 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
<div class="pf-c-select__toggle pf-m-typeahead" part="ak-search-select-toggle">
<div class="pf-c-select__toggle-wrapper" part="ak-search-select-wrapper">
<input
?required=${!this.blankable}
part="ak-search-select-toggle-typeahead"
autocomplete="off"
class="pf-c-form-control pf-c-select__toggle-typeahead"
type="text"
id=${ifDefined(this.fieldID)}
${ref(this.#inputRef)}
${ref(this.inputRef)}
placeholder=${this.placeholder}
aria-label=${ifDefined(this.label)}
name=${ifDefined(this.name)}
spellcheck="false"
@input=${this.#inputListener}
@click=${this.#clickListener}
@blur=${this.#blurListener}
@keyup=${this.#searchKeyupListener}
@keydown=${this.#searchKeydownListener}
@input=${this.onInput}
@click=${this.onClick}
@blur=${this.onListBlur}
@keydown=${this.onKeydown}
value=${this.displayValue}
/>
</div>
@@ -436,26 +377,34 @@ export class SearchSelectView extends AKElement implements ISearchSelectView {
? html`
<ak-portal
name=${ifDefined(this.name)}
.anchor=${this.#inputRef.value}
.anchor=${this.inputRef.value}
?open=${open}
>
<ak-list-select
id="menu-${this.getAttribute("data-ouia-component-id")}"
${ref(this.#menuRef)}
${ref(this.menuRef)}
.options=${this.managedOptions}
value=${ifDefined(this.value)}
@change=${this.#changeListener}
@blur=${this.#blurListener}
@change=${this.onListChange}
@blur=${this.onListBlur}
emptyOption=${ifDefined(emptyOption)}
@keydown=${this.#listKeydownListener}
@keyup=${this.#listKeyupListener}
@keydown=${this.onListKeydown}
></ak-list-select>
</ak-portal>
`
: nothing}`;
}
//#endregion
public override updated() {
this.setAttribute("data-ouia-component-safe", "true");
}
public override firstUpdated() {
// Route around Lit's scheduling algorithm complaining about re-renders
window.setTimeout(() => {
this.inputRefIsAvailable = Boolean(this.inputRef?.value);
}, 0);
}
}
declare global {

View File

@@ -9,7 +9,7 @@ export interface ISearchSelect<T> extends ISearchSelectBase<T> {
fetchObjects: (query?: string) => Promise<T[]>;
renderElement: (element: T) => string;
renderDescription?: (element: T) => string | TemplateResult;
value: (element: T | null) => string;
value: (element: T | undefined) => string;
selected?: (element: T, elements: T[]) => boolean;
groupBy: (items: T[]) => [string, T[]][];
}
@@ -44,28 +44,44 @@ export interface ISearchSelect<T> extends ISearchSelectBase<T> {
* consequence of the user typing or when selecting from the list.
*
*/
@customElement("ak-search-select")
export class SearchSelect<T> extends SearchSelectBase<T> implements ISearchSelect<T> {
static styles = [...SearchSelectBase.styles];
// A function which takes the query state object (accepting that it may be empty) and returns a
// new collection of objects.
@property({ attribute: false })
public fetchObjects!: (query?: string) => Promise<T[]>;
fetchObjects!: (query?: string) => Promise<T[]>;
// A function passed to this object that extracts a string representation of items of the
// collection under search.
@property({ attribute: false })
public renderElement!: (element: T) => string;
renderElement!: (element: T) => string;
// A function passed to this object that extracts an HTML representation of additional
// information for items of the collection under search.
@property({ attribute: false })
public renderDescription?: (element: T) => string | TemplateResult;
renderDescription?: (element: T) => string | TemplateResult;
// A function which returns the currently selected object's primary key, used for serialization
// into forms.
@property({ attribute: false })
public value!: (element: T | null) => string;
value!: (element: T | undefined) => string;
// A function passed to this object that determines an object in the collection under search
// should be automatically selected. Only used when the search itself is responsible for
// fetching the data; sets an initial default value.
@property({ attribute: false })
public selected?: (element: T, elements: T[]) => boolean;
selected?: (element: T, elements: T[]) => boolean;
// A function passed to this object (or using the default below) that groups objects in the
// collection under search into categories.
@property({ attribute: false })
public groupBy: (items: T[]) => [string, T[]][] = (items: T[]): [string, T[]][] => {
return groupBy(items, () => "");
groupBy: (items: T[]) => [string, T[]][] = (items: T[]): [string, T[]][] => {
return groupBy(items, () => {
return "";
});
};
}

View File

@@ -95,7 +95,7 @@ export const GroupedAndEz = () => {
const config: ISearchSelectApi<Sample> = {
fetchObjects: getSamples,
renderElement: (sample: Sample) => sample.name,
value: (sample: Sample | null) => sample?.pk ?? "",
value: (sample: Sample | undefined) => sample?.pk ?? "",
groupBy: (samples: Sample[]) =>
groupBy(samples, (sample: Sample) => sample.season[0] ?? ""),
};

View File

@@ -54,19 +54,6 @@ export type LitPropertyRecord<T extends object> = {
*/
export type LitPropertyKey<K> = K extends string ? `.${K}` | `?${K}` | K : K;
/**
* A React-like functional component. Used to render a component in a template.
*
* @template P The type of the props object.
* @param props The props object.
* @param children The children to render.
* @returns The rendered template.
*/
export type LitFC<P> = (
props: P,
children?: SlottedTemplateResult,
) => SlottedTemplateResult | SlottedTemplateResult[];
//#endregion
//#region Host/Controller

View File

@@ -7,11 +7,6 @@ export type NamedElement<T = Element> = T & {
name: string;
};
/**
* Type predicate to check if an element currently has a `name` attribute.
*
* @see {@linkcode isNameableElement} to check if an element is nameable.
*/
export function isNamedElement(element: Element): element is NamedElement {
if (!(element instanceof HTMLElement)) {
return false;
@@ -20,57 +15,27 @@ export function isNamedElement(element: Element): element is NamedElement {
return "name" in element.attributes;
}
/**
* A set of elements that can be named, i.e. have a `name` attribute.
*
* @deprecated This should be replaced with a less brittle approach.
*/
const NameableElements = new Set([
"INPUT",
"TEXTAREA",
"SELECT",
"AK-CODEMIRROR",
"AK-CHIP-GROUP",
"AK-SEARCH-SELECT",
"AK-RADIO",
]);
/**
* Type predicate to check if an element is nameable.
*
* @see {@linkcode isNamedElement} to check if an element currently has a `name` attribute.
*/
export function isNameableElement(element: Element): element is NamedElement {
if (!(element instanceof HTMLElement)) {
return false;
}
return NameableElements.has(element.tagName);
}
/**
* Create a map of files provided by input elements within the given iterable.
*/
export function createFileMap<T extends PropertyKey = PropertyKey>(
fileInputParents?: Iterable<LitElement> | null,
fileInputParents?: Iterable<NamedElement<LitElement>> | null,
): Map<T, File> {
const record = new Map<T, File>();
for (const element of fileInputParents || []) {
element.requestUpdate();
if (!isNamedElement(element)) continue;
const inputElement = element.querySelector<HTMLInputElement>("input[type=file]");
if (!inputElement) continue;
const file = inputElement.files?.[0];
const name = element.name as T;
const name = element.name;
if (!file || !name) continue;
record.set(name, file);
record.set(name as T, file);
}
return record;

View File

@@ -1,9 +1,9 @@
import "#elements/forms/FormElement";
import { AKElement } from "#elements/Base";
import { bound } from "#elements/decorators/bound";
import { isActiveElement } from "#elements/utils/focus";
import { AKLabel } from "#components/ak-label";
import { msg } from "@lit/localize";
import { html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators.js";
@@ -12,7 +12,6 @@ import { ifDefined } from "lit/directives/if-defined.js";
import { createRef, ref, Ref } from "lit/directives/ref.js";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -41,7 +40,7 @@ const Visibility = {
@customElement("ak-flow-input-password")
export class InputPassword extends AKElement {
static styles = [PFBase, PFForm, PFInputGroup, PFFormControl, PFButton];
static styles = [PFBase, PFInputGroup, PFFormControl, PFButton];
//#region Properties
@@ -51,7 +50,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: String, attribute: "input-id" })
public inputID = "ak-stage-password-input";
inputId = "ak-stage-password-input";
/**
* The name of the input field.
@@ -59,7 +58,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: String })
public name = "password";
name = "password";
/**
* The label for the input field.
@@ -67,7 +66,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: String })
public label = msg("Password");
label = msg("Password");
/**
* The placeholder text for the input field.
@@ -75,7 +74,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: String })
public placeholder = msg("Please enter your password");
placeholder = msg("Please enter your password");
/**
* The initial value of the input field.
@@ -83,20 +82,20 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: String, attribute: "prefill" })
public initialValue = "";
initialValue = "";
/**
* The errors for the input field.
*/
@property({ type: Object })
public errors: Record<string, string> = {};
errors: Record<string, string> = {};
/**
* Forwarded to the input tag's aria-invalid attribute, if set
* @attr
*/
@property({ type: String })
public invalid?: string;
invalid?: string;
/**
* Whether to allow the user to toggle the visibility of the password.
@@ -104,7 +103,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: Boolean, attribute: "allow-show-password" })
public allowShowPassword = false;
allowShowPassword = false;
/**
* Whether the password is currently visible.
@@ -112,7 +111,7 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: Boolean, attribute: "password-visible" })
public passwordVisible = false;
passwordVisible = false;
/**
* Automatically grab focus after rendering.
@@ -120,15 +119,15 @@ export class InputPassword extends AKElement {
* @attr
*/
@property({ type: Boolean, attribute: "grab-focus" })
public grabFocus = false;
grabFocus = false;
//#endregion
//#region Refs
public inputRef: Ref<HTMLInputElement> = createRef();
inputRef: Ref<HTMLInputElement> = createRef();
public toggleVisibilityRef: Ref<HTMLButtonElement> = createRef();
toggleVisibilityRef: Ref<HTMLButtonElement> = createRef();
//#endregion
@@ -138,7 +137,7 @@ export class InputPassword extends AKElement {
* Whether the caps lock key is enabled.
*/
@state()
public capsLock = false;
capsLock = false;
//#endregion
@@ -315,33 +314,37 @@ export class InputPassword extends AKElement {
}
render() {
return html` ${AKLabel({ required: true, htmlFor: this.inputID }, this.label)}
<div class="pf-c-form__group">
<div class="pf-c-form__group-control">
<div class="pf-c-input-group">
<input
type=${this.passwordVisible ? "text" : "password"}
id=${this.inputID}
name=${this.name}
placeholder=${this.placeholder}
autocomplete="current-password"
class="${classMap({
"pf-c-form-control": true,
"pf-m-icon": true,
"pf-m-caps-lock": this.capsLock,
})}"
required
aria-invalid=${ifDefined(this.invalid)}
value=${this.initialValue}
${ref(this.inputRef)}
/>
return html` <ak-form-element
label="${this.label}"
required
class="pf-c-form__group"
.errors=${this.errors}
>
<div class="pf-c-form__group-control">
<div class="pf-c-input-group">
<input
type=${this.passwordVisible ? "text" : "password"}
id=${this.inputId}
name=${this.name}
placeholder=${this.placeholder}
autocomplete="current-password"
class="${classMap({
"pf-c-form-control": true,
"pf-m-icon": true,
"pf-m-caps-lock": this.capsLock,
})}"
required
aria-invalid=${ifDefined(this.invalid)}
value=${this.initialValue}
${ref(this.inputRef)}
/>
${this.renderVisibilityToggle()}
</div>
${this.renderHelperText()}
${this.renderVisibilityToggle()}
</div>
</div>`;
${this.renderHelperText()}
</div>
</ak-form-element>`;
}
//#endregion

View File

@@ -1,9 +1,7 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseStage } from "#flow/stages/base";
import {
@@ -18,7 +16,6 @@ import { customElement } from "lit/decorators.js";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -28,24 +25,15 @@ export class OAuth2DeviceCode extends BaseStage<
OAuthDeviceCodeChallenge,
OAuthDeviceCodeChallengeResponseRequest
> {
static styles: CSSResult[] = [
PFBase,
PFLogin,
PFForm,
PFFormControl,
PFTitle,
PFButton,
PFInputGroup,
];
static styles: CSSResult[] = [PFBase, PFLogin, PFForm, PFFormControl, PFTitle, PFButton];
render(): TemplateResult {
return html`<ak-flow-card .challenge=${this.challenge}>
<form class="pf-c-form" @submit=${this.submitForm}>
<div class="pf-c-form__group">
${AKLabel({ required: true, htmlFor: "device-code-input" }, msg("Device Code"))}
<form
class="pf-c-form"
@submit=${this.submitForm}
>
<input
id="device-code-input"
type="text"
name="code"
inputmode="numeric"
@@ -57,8 +45,7 @@ export class OAuth2DeviceCode extends BaseStage<
value=""
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.code })}
</div>
</ak-form-element>
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";

View File

@@ -1,9 +1,7 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseStage } from "#flow/stages/base";
import {
@@ -20,7 +18,6 @@ import PFAlert from "@patternfly/patternfly/components/Alert/alert.css";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -36,7 +33,6 @@ export class AuthenticatorEmailStage extends BaseStage<
PFLogin,
PFForm,
PFFormControl,
PFInputGroup,
PFTitle,
PFButton,
];
@@ -55,13 +51,13 @@ export class AuthenticatorEmailStage extends BaseStage<
>
</div>
</ak-form-static>
<div class="pf-c-form__group">
${AKLabel(
{ required: true, htmlFor: "email-input" },
msg("Configure your email"),
)}
<ak-form-element
label="${msg("Configure your email")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).email}
>
<input
id="email-input"
type="email"
name="email"
placeholder="${msg("Please enter your email address.")}"
@@ -70,8 +66,7 @@ export class AuthenticatorEmailStage extends BaseStage<
class="pf-c-form-control"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.email })}
</div>
</ak-form-element>
${this.renderNonFieldErrors()}
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">
@@ -98,10 +93,13 @@ export class AuthenticatorEmailStage extends BaseStage<
A verification token has been sent to your configured email address
${ifDefined(this.challenge.email)}
<form class="pf-c-form" @submit=${this.submitForm}>
<div class="pf-c-form__group">
${AKLabel({ required: true, htmlFor: "code-input" }, msg("Code"))}
<ak-form-element
label="${msg("Code")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).code}
>
<input
id="code-input"
type="text"
name="code"
inputmode="numeric"
@@ -112,8 +110,7 @@ export class AuthenticatorEmailStage extends BaseStage<
class="pf-c-form-control"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.code })}
</div>
</ak-form-element>
${this.renderNonFieldErrors()}
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">

View File

@@ -1,9 +1,7 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseStage } from "#flow/stages/base";
import {
@@ -20,7 +18,6 @@ import PFAlert from "@patternfly/patternfly/components/Alert/alert.css";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -36,18 +33,15 @@ export class AuthenticatorSMSStage extends BaseStage<
PFLogin,
PFForm,
PFFormControl,
PFInputGroup,
PFTitle,
PFButton,
];
renderPhoneNumber(): TemplateResult {
return html`<ak-flow-card .challenge=${this.challenge}>
<form class="pf-c-form" @submit=${this.submitForm}>
<ak-form-static
class="pf-c-form__group"
userAvatar=${this.challenge.pendingUserAvatar}
user=${this.challenge.pendingUser}
<form
class="pf-c-form"
@submit=${this.submitForm}
>
<div slot="link">
<a href="${ifDefined(this.challenge.flowInfo?.cancelUrl)}"
@@ -55,12 +49,12 @@ export class AuthenticatorSMSStage extends BaseStage<
>
</div>
</ak-form-static>
<div class="pf-c-form__group">
${AKLabel(
{ required: true, htmlFor: "phone-number-input" },
msg("Phone number"),
)}
<ak-form-element
label="${msg("Phone number")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).phone_number}
>
<input
type="tel"
name="phoneNumber"
@@ -70,8 +64,7 @@ export class AuthenticatorSMSStage extends BaseStage<
class="pf-c-form-control"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.phone_number })}
</div>
</ak-form-element>
${this.renderNonFieldErrors()}
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">
@@ -96,10 +89,13 @@ export class AuthenticatorSMSStage extends BaseStage<
>
</div>
</ak-form-static>
<div class="pf-c-form__group">
${AKLabel({ required: true, htmlFor: "sms-code-input" }, msg("Code"))}
<ak-form-element
label="${msg("Code")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).code}
>
<input
id="sms-code-input"
type="text"
name="code"
inputmode="numeric"
@@ -110,8 +106,7 @@ export class AuthenticatorSMSStage extends BaseStage<
class="pf-c-form-control"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.code })}
</div>
</ak-form-element>
${this.renderNonFieldErrors()}
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
@@ -63,13 +64,13 @@ export class AuthenticatorStaticStage extends BaseStage<
>
</div>
</ak-form-static>
<div class="pf-c-form__group">
<ak-form-element label="" class="pf-c-form__group">
<ul>
${this.challenge.codes.map((token) => {
return html`<li class="pf-m-monospace">${token}</li>`;
})}
</ul>
</div>
</ak-form-element>
<p>${msg("Make sure to keep these tokens in a safe place.")}</p>
<div class="pf-c-form__group pf-m-action">

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
import "webcomponent-qr-code";
@@ -6,9 +7,6 @@ import { MessageLevel } from "#common/messages";
import { showMessage } from "#elements/messages/MessageContainer";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseStage } from "#flow/stages/base";
import {
@@ -24,7 +22,6 @@ import { ifDefined } from "lit/directives/if-defined.js";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -39,7 +36,6 @@ export class AuthenticatorTOTPStage extends BaseStage<
PFLogin,
PFForm,
PFFormControl,
PFInputGroup,
PFTitle,
PFButton,
css`
@@ -66,8 +62,7 @@ export class AuthenticatorTOTPStage extends BaseStage<
</div>
</ak-form-static>
<input type="hidden" name="otp_uri" value=${this.challenge.configUrl} />
<div class="pf-c-form__group">
<ak-form-element>
<div class="qr-container">
<qr-code data="${this.challenge.configUrl}"></qr-code>
<button
@@ -97,16 +92,20 @@ export class AuthenticatorTOTPStage extends BaseStage<
${msg("Copy")}
</button>
</div>
</div>
</ak-form-element>
<p>
${msg(
"Please scan the QR code above using the Microsoft Authenticator, Google Authenticator, or other authenticator apps on your device, and enter the code the device displays below to finish setting up the MFA device.",
)}
</p>
<div class="pf-c-form__group">
${AKLabel({ required: true, htmlFor: "totp-code-input" }, msg("Code"))}
<ak-form-element
label="${msg("Code")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).code}
>
<!-- @ts-ignore -->
<input
id="totp-code-input"
type="text"
name="code"
inputmode="numeric"
@@ -118,8 +117,7 @@ export class AuthenticatorTOTPStage extends BaseStage<
spellcheck="false"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.code })}
</div>
</ak-form-element>
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">

View File

@@ -1,8 +1,6 @@
import "#elements/forms/FormElement";
import "#flow/components/ak-flow-card";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseDeviceStage } from "#flow/stages/authenticator_validate/base";
import { PasswordManagerPrefill } from "#flow/stages/identification/IdentificationStage";
@@ -76,15 +74,16 @@ export class AuthenticatorValidateStageWebCode extends BaseDeviceStage<
<i class="fa ${this.deviceIcon()}" aria-hidden="true"></i>
<p>${this.deviceMessage()}</p>
</div>
<div class="pf-c-form__group">
${AKLabel(
{ required: true, htmlFor: "validation-code-input" },
this.deviceChallenge?.deviceClass === DeviceClassesEnum.Static
? msg("Static token")
: msg("Authentication code"),
)}
<ak-form-element
label="${this.deviceChallenge?.deviceClass === DeviceClassesEnum.Static
? msg("Static token")
: msg("Authentication code")}"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).code}
>
<!-- @ts-ignore -->
<input
id="validation-code-input"
type="text"
name="code"
inputmode="${this.deviceChallenge?.deviceClass === DeviceClassesEnum.Static
@@ -100,8 +99,7 @@ export class AuthenticatorValidateStageWebCode extends BaseDeviceStage<
value="${PasswordManagerPrefill.totp || ""}"
required
/>
${AKFormErrors({ errors: this.challenge.responseErrors?.code })}
</div>
</ak-form-element>
<div class="pf-c-form__group pf-m-action">
<button type="submit" class="pf-c-button pf-m-primary pf-m-block">

View File

@@ -1,4 +1,5 @@
import "#elements/EmptyState";
import "#elements/forms/FormElement";
import { BaseDeviceStage } from "#flow/stages/authenticator_validate/base";

View File

@@ -10,7 +10,6 @@ import { property } from "lit/decorators.js";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -30,7 +29,6 @@ export class BaseDeviceStage<
PFLogin,
PFForm,
PFFormControl,
PFInputGroup,
PFTitle,
PFButton,
css`

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";

View File

@@ -1,12 +1,10 @@
import "#elements/Divider";
import "#elements/EmptyState";
import "#elements/forms/FormElement";
import "#flow/components/ak-flow-card";
import "#flow/components/ak-flow-password-input";
import "#flow/stages/captcha/CaptchaStage";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { renderSourceIcon } from "#admin/sources/utils";
import { BaseStage } from "#flow/stages/base";
@@ -22,7 +20,7 @@ import {
import { msg, str } from "@lit/localize";
import { css, CSSResult, html, nothing, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { customElement, state } from "lit/decorators.js";
import { createRef, ref } from "lit/directives/ref.js";
import PFAlert from "@patternfly/patternfly/components/Alert/alert.css";
@@ -89,14 +87,6 @@ export class IdentificationStage extends BaseStage<
`,
];
/**
* The ID of the input field.
*
* @attr
*/
@property({ type: String, attribute: "input-id" })
public inputID = "ak-identifier-input";
#form?: HTMLFormElement;
#rememberMe = new AkRememberMeController(this);
@@ -311,7 +301,6 @@ export class IdentificationStage extends BaseStage<
[UserFieldsEnum.Upn]: msg("UPN"),
};
const label = OR_LIST_FORMATTERS.format(fields.map((f) => uiFields[f]));
return html`${this.challenge.flowDesignation === FlowDesignationEnum.Recovery
? html`
<p>
@@ -321,10 +310,13 @@ export class IdentificationStage extends BaseStage<
</p>
`
: nothing}
<div class="pf-c-form__group">
${AKLabel({ required: true, htmlFor: this.inputID }, label)}
<ak-form-element
label=${label}
required
class="pf-c-form__group"
.errors=${(this.challenge.responseErrors || {}).uid_field}
>
<input
id=${this.inputID}
type=${type}
name="uidField"
placeholder=${label}
@@ -336,13 +328,12 @@ export class IdentificationStage extends BaseStage<
required
/>
${this.#rememberMe.render()}
${AKFormErrors({ errors: this.challenge.responseErrors?.uid_field })}
</div>
</ak-form-element>
${this.challenge.passwordFields
? html`
<ak-flow-input-password
label=${msg("Password")}
input-idd="ak-stage-identification-password"
inputId="ak-stage-identification-password"
required
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {}).password}

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";
import "#flow/components/ak-flow-password-input";

View File

@@ -1,12 +1,10 @@
import "#elements/Divider";
import "#elements/forms/FormElement";
import "#flow/components/ak-flow-card";
import { LOCALES } from "#elements/ak-locale-context/definitions";
import { CapabilitiesEnum, WithCapabilitiesConfig } from "#elements/mixins/capabilities";
import { AKFormErrors } from "#components/ak-field-errors";
import { AKLabel } from "#components/ak-label";
import { BaseStage } from "#flow/stages/base";
import {
@@ -26,7 +24,6 @@ import PFButton from "@patternfly/patternfly/components/Button/button.css";
import PFCheck from "@patternfly/patternfly/components/Check/check.css";
import PFForm from "@patternfly/patternfly/components/Form/form.css";
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";
import PFLogin from "@patternfly/patternfly/components/Login/login.css";
import PFTitle from "@patternfly/patternfly/components/Title/title.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";
@@ -41,7 +38,6 @@ export class PromptStage extends WithCapabilitiesConfig(
PFAlert,
PFForm,
PFFormControl,
PFInputGroup,
PFTitle,
PFButton,
PFCheck,
@@ -59,7 +55,6 @@ export class PromptStage extends WithCapabilitiesConfig(
case PromptTypeEnum.Text:
return html`<input
type="text"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
autocomplete="off"
@@ -69,7 +64,6 @@ export class PromptStage extends WithCapabilitiesConfig(
/>`;
case PromptTypeEnum.TextArea:
return html`<textarea
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
autocomplete="off"
@@ -81,7 +75,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.TextReadOnly:
return html`<input
type="text"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -90,7 +83,6 @@ ${prompt.initialValue}</textarea
/>`;
case PromptTypeEnum.TextAreaReadOnly:
return html`<textarea
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -101,7 +93,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Username:
return html`<input
type="text"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
autocomplete="username"
@@ -113,7 +104,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Email:
return html`<input
type="email"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -123,7 +113,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Password:
return html`<input
type="password"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
autocomplete="new-password"
@@ -133,7 +122,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Number:
return html`<input
type="number"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -143,7 +131,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Date:
return html`<input
type="date"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -153,7 +140,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.DateTime:
return html`<input
type="datetime"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -163,7 +149,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.File:
return html`<input
type="file"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
@@ -175,7 +160,6 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Hidden:
return html`<input
type="hidden"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
value="${prompt.initialValue}"
class="pf-c-form-control"
@@ -184,11 +168,7 @@ ${prompt.initialValue}</textarea
case PromptTypeEnum.Static:
return html`<p>${unsafeHTML(prompt.initialValue)}</p>`;
case PromptTypeEnum.Dropdown:
return html`<select
class="pf-c-form-control"
id="field-${prompt.fieldKey}"
name="${prompt.fieldKey}"
>
return html`<select class="pf-c-form-control" name="${prompt.fieldKey}">
${prompt.choices?.map((choice) => {
return html`<option
value="${choice}"
@@ -276,19 +256,14 @@ ${prompt.initialValue}</textarea
</div>`;
}
if (this.shouldRenderInWrapper(prompt)) {
const errors = (this.challenge?.responseErrors || {})[prompt.fieldKey];
return html`<div class="pf-c-form__group">
${AKLabel(
{
required: prompt.required,
htmlFor: `field-${prompt.fieldKey}`,
},
prompt.label,
)}
return html`<ak-form-element
label="${prompt.label}"
?required="${prompt.required}"
class="pf-c-form__group"
.errors=${(this.challenge?.responseErrors || {})[prompt.fieldKey]}
>
${this.renderPromptInner(prompt)} ${this.renderPromptHelpText(prompt)}
${AKFormErrors({ errors })}
</div>`;
</ak-form-element>`;
}
return html` ${this.renderPromptInner(prompt)} ${this.renderPromptHelpText(prompt)}`;
}
@@ -304,7 +279,9 @@ ${prompt.initialValue}</textarea
render(): TemplateResult {
return html`<ak-flow-card .challenge=${this.challenge}>
<form class="pf-c-form" @submit=${this.submitForm}>
${this.challenge.fields.map((prompt) => this.renderField(prompt))}
${this.challenge.fields.map((prompt) => {
return this.renderField(prompt);
})}
${this.renderNonFieldErrors()} ${this.renderContinue()}
</form>
</ak-flow-card>`;

View File

@@ -1,3 +1,4 @@
import "#elements/forms/FormElement";
import "#flow/FormStatic";
import "#flow/components/ak-flow-card";

View File

@@ -184,7 +184,7 @@ export class LibraryPage extends AKElement {
render() {
return html`<main role="main" class="pf-c-page__main" tabindex="-1" id="main-content">
<div class="pf-c-content header">
<h1 role="heading" aria-level="1" data-test-id="page-heading">
<h1 role="heading" aria-level="1" id="library-page-title">
${msg("My applications")}
</h1>
${this.uiConfig.searchEnabled ? this.renderSearch() : nothing}
@@ -193,13 +193,3 @@ export class LibraryPage extends AKElement {
</main>`;
}
}
declare global {
interface PageTestIDMap {
heading: HTMLHeadingElement;
}
interface TestIDSelectorMap {
page: PageTestIDMap;
}
}

View File

@@ -27,16 +27,17 @@ export class UserSettingsPromptStage extends PromptStage {
}
renderField(prompt: StagePrompt): TemplateResult {
const errors = this.challenge?.responseErrors?.[prompt.fieldKey];
const errors = (this.challenge?.responseErrors || {})[prompt.fieldKey];
if (this.shouldRenderInWrapper(prompt)) {
return html`
<ak-form-element-horizontal
label=${msg(str`${prompt.label}`)}
?required=${prompt.required}
name=${prompt.fieldKey}
?invalid=${!!errors}
.errorMessages=${errors}
?invalid=${errors !== undefined}
.errorMessages=${(errors || []).map((error) => {
return error.string;
})}
>
${this.renderPromptInner(prompt)} ${this.renderPromptHelpText(prompt)}
</ak-form-element-horizontal>

View File

@@ -1,217 +0,0 @@
import { expect, test } from "#e2e";
import { createRandomName } from "#e2e/utils/generators";
import { ConsoleLogger } from "#logger/node";
import { IDGenerator } from "@goauthentik/core/id";
import { series } from "@goauthentik/core/promises";
test.describe("Provider Wizard", () => {
const providerNames = new Map<string, string>();
//#region Lifecycle
test.beforeEach("Configure Providers", async ({ page, session }, { testId }) => {
const seed = IDGenerator.randomID(6);
const providerName = `${createRandomName({ seed })} (${seed})`;
providerNames.set(testId, providerName);
const wizard = page.getByRole("dialog", { name: "New provider" });
await test.step("Authenticate", async () => {
await session.login({
to: "/if/admin/#/core/providers",
});
});
await test.step("Navigate to provider wizard", async () => {
await expect(wizard, "Wizard is initially closed").toBeHidden();
await page.getByRole("button", { name: "New Provider" }).click();
await expect(wizard, "Wizard opens after clicking on New Provider").toBeVisible();
await expect(
page.getByRole("listbox", { name: "Select a provider type" }),
"Wizard opens with a list of provider types",
).toBeVisible();
await expect(
wizard.getByRole("navigation").getByRole("button", {
name: /next|finish/i,
}),
"Wizard can't be navigated to next step",
).toBeDisabled();
});
});
test.afterEach("Verification", async ({ page }, { testId }) => {
//#region Confirm provider
const providerName = providerNames.get(testId)!;
const $provider = await test.step("Find provider via search", async () => {
const searchInput = page.getByRole("search").getByPlaceholder("Search for providers");
await searchInput.fill(providerName);
// We have to wait for the provider to appear in the table,
// but several UI elements will be rendered asynchronously.
// We attempt several times to find the provider to avoid flakiness.
const tries = 10;
let found = false;
for (let i = 0; i < tries; i++) {
await searchInput.press("Enter");
await searchInput.blur();
const $rowEntry = page.getByRole("row", {
name: providerName,
});
ConsoleLogger.info(
`${i + 1}/${tries} Waiting for provider ${providerName} to appear in the table`,
);
found = await $rowEntry
.waitFor({
timeout: 1500,
})
.then(() => true)
.catch(() => false);
if (found) {
ConsoleLogger.info(`Provider ${providerName} found in the table`);
return $rowEntry;
}
}
throw new Error(`Provider ${providerName} not found in the table`);
});
await expect($provider, "Provider is visible").toBeVisible();
//#endregion
});
//#endregion
//#region OAuth2
test("Simple OAuth2 Provider", async ({ form, pointer }, testInfo) => {
const providerName = providerNames.get(testInfo.testId)!;
const { fill, selectSearchValue } = form;
const { click } = pointer;
await series(
[click, "OAuth2/OpenID", "option"],
[click, "Next"],
[fill, "Provider name", providerName],
[
selectSearchValue,
"Authorization flow",
/default-provider-authorization-explicit-consent/,
],
[click, "Finish"],
);
});
test("Complete OAuth2 Provider", async ({ page, form, pointer }, testInfo) => {
const providerName = providerNames.get(testInfo.testId)!;
const { fill, selectSearchValue, setFormGroup, setRadio, setInputCheck } = form;
const { click } = pointer;
const $clientSecretInput = page.getByRole("textbox", { name: "Client Secret" });
await series(
[click, "OAuth2/OpenID", "option"],
[click, "Next"],
[fill, "Provider name", providerName],
[
selectSearchValue,
"Authorization flow",
/default-provider-authorization-explicit-consent/,
],
[setFormGroup, "Protocol settings", true],
[setRadio, "Client Type", "Public"],
[
expect(
$clientSecretInput,
"Client Secret should be hidden when Client Type is Public",
).toBeHidden,
],
[setRadio, "Client Type", "Confidential"],
[
expect(
$clientSecretInput,
"Client Secret should be visible when Client Type is Confidential",
).toBeVisible,
],
[selectSearchValue, "Signing Key", /authentik Self-signed Certificate/],
[selectSearchValue, "Encryption Key", /authentik Self-signed Certificate/],
[setFormGroup, "Advanced flow settings", true],
[selectSearchValue, "Authentication flow", /default-source-authentication/],
[selectSearchValue, "Invalidation flow", /default-invalidation-flow/],
[setFormGroup, "Advanced protocol settings", true],
[fill, "Access code validity", "minutes=2"],
[fill, "Access token validity", "minutes=10"],
[fill, "Refresh token validity", "days=40"],
[setInputCheck, "Include claims in id_token", false],
[setRadio, "Subject mode", "Based on the User's username"],
[setRadio, "Issuer mode", "Same identifier is used for all providers"],
[setFormGroup, "Machine-to-Machine authentication settings", true],
[click, "Finish", "button", page.getByRole("dialog", { name: "New Provider" })],
);
});
//#endregion
//#region LDAP
test("Complete LDAP Provider", async ({ page, pointer, form }, testInfo) => {
const providerName = providerNames.get(testInfo.testId)!;
const { fill, setFormGroup, selectSearchValue, setInputCheck, setRadio } = form;
const { click } = pointer;
await series(
[click, "LDAP", "option"],
[click, "Next"],
[fill, "Provider name", providerName],
[setFormGroup, "Flow settings", true],
[setFormGroup, "Protocol settings", true],
[selectSearchValue, "Bind flow", /default-authentication-flow/],
[fill, "Base DN", "DC=ldap-2,DC=goauthentik,DC=io"],
[selectSearchValue, "Certificate", /authentik Self-signed Certificate/],
[fill, "TLS Server name", "goauthentik.io"],
[fill, "UID start number", "2001"],
[fill, "GID start number", "4001"],
[setRadio, "Search mode", "Direct querying"],
[setRadio, "Bind mode", "Direct binding"],
[setInputCheck, "MFA Support", false],
[click, "Finish", "button", page.getByRole("dialog", { name: "New Provider" })],
);
});
//#endregion
//#region RADIUS
test("Complete RADIUS Provider", async ({ page, pointer, form }, testInfo) => {
const providerName = providerNames.get(testInfo.testId)!;
const { fill, selectSearchValue } = form;
const { click } = pointer;
await series(
[click, "RADIUS", "option"],
[click, "Next"],
[fill, "Provider name", providerName],
[selectSearchValue, "Authentication flow", /default-authentication-flow/],
[click, "Finish", "button", page.getByRole("dialog", { name: "New Provider" })],
);
});
//#endregion
});

View File

@@ -1,33 +0,0 @@
import { expect, test } from "#e2e";
import {
BAD_PASSWORD,
BAD_USERNAME,
GOOD_PASSWORD,
GOOD_USERNAME,
} from "#e2e/fixtures/SessionFixture";
test.beforeEach(async ({ session }) => {
await session.toLoginPage();
});
test.describe("Session management", () => {
test("Login with valid credentials", async ({ session, $ }) => {
await session.login({ username: GOOD_USERNAME, password: GOOD_PASSWORD });
await $.page.heading.expect.toHaveText("My applications");
});
test("Reject bad username", async ({ session }) => {
await session.login({ username: BAD_USERNAME, password: GOOD_PASSWORD });
await expect(session.$authFailureMessage).toBeVisible();
await expect(session.$authFailureMessage).toHaveText("Invalid password");
});
test("Reject bad password", async ({ session }) => {
await session.login({ username: GOOD_USERNAME, password: BAD_PASSWORD });
await expect(session.$authFailureMessage).toBeVisible();
await expect(session.$authFailureMessage).toHaveText("Invalid password");
});
});

View File

@@ -1,87 +0,0 @@
/**
* @file Vitest browser utilities for Lit.
*
* @import { LocatorSelectors } from '@vitest/browser/context'
* @import { PrettyDOMOptions } from '@vitest/browser/utils'
* @import { RenderOptions as LitRenderOptions } from 'lit'
*/
import { debug, getElementLocatorSelectors } from "@vitest/browser/utils";
import { render as renderLit } from "lit";
/**
* @implements {Disposable}
*/
export class LitViteContext {
/**
* @type {Set<Disposable>}
*/
static #resources = new Set();
/**
* @param {unknown} template
* @param {HTMLElement} [container]
* @param {LitRenderOptions} [options]
*
* @returns {LitViteContext}
*/
static render = (template, container = document.createElement("div"), options) => {
const context = new LitViteContext(container);
context.render(template, options);
return context;
};
static [Symbol.dispose] = () => {
this.#resources.forEach((resource) => resource[Symbol.dispose]());
this.#resources.clear();
};
static cleanup = () => {
return this[Symbol.dispose]();
};
/**
* @param {unknown} template
* @param {LitRenderOptions} [options]
*/
render(template, options) {
return renderLit(template, this.container, options);
}
/**
* @type {HTMLElement} container
*/
container;
/**
* @type {LocatorSelectors}
*/
$;
/**
* @param {HTMLElement} container
*/
constructor(container) {
this.container = container;
this.$ = getElementLocatorSelectors(container);
}
toFragment() {
return document.createRange().createContextualFragment(this.container.innerHTML);
}
/**
* @param {number} [maxLength]
* @param {PrettyDOMOptions} [options]
*/
debug(maxLength, options) {
return debug(this.container, maxLength, options);
}
[Symbol.dispose] = () => {
this.container.remove();
LitViteContext.#resources.delete(this);
};
}

View File

@@ -1,12 +0,0 @@
import { LitViteContext } from "./rendering.js";
import { page } from "@vitest/browser/context";
import { beforeEach } from "vitest";
page.extend({
// @ts-ignore
renderLit: LitViteContext.render,
[Symbol.for("vitest:component-cleanup")]: LitViteContext.cleanup,
});
beforeEach(() => LitViteContext.cleanup());

View File

@@ -1,9 +0,0 @@
import { expect, test } from "vitest";
function sum(a: number, b: number) {
return a + b;
}
test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
});

View File

@@ -1,5 +1,6 @@
{
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"moduleResolution": "node",
"module": "ESNext",

View File

@@ -2,11 +2,5 @@
{
"extends": "./tsconfig.json",
"exclude": [
// ---
"src/**/*.test.ts",
"src/**/*.comp.ts",
"./**/*.stories.ts",
"./tests"
]
"exclude": ["src/**/*.test.ts", "./tests"]
}

View File

@@ -1,5 +1,24 @@
// @file TSConfig used by the web package during build.
// @file TSConfig used during tests.
{
"extends": "./tsconfig.json"
"compilerOptions": {
"baseUrl": ".",
"types": ["node", "webdriverio/async", "@wdio/cucumber-framework", "expect-webdriverio"],
"target": "esnext",
"module": "esnext",
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"lib": [
"ES5",
"ES2015",
"ES2016",
"ES2017",
"ES2018",
"ES2019",
"ES2020",
"ESNext",
"DOM",
"DOM.Iterable",
"WebWorker"
]
}
}

23
web/types/node.d.ts vendored
View File

@@ -14,13 +14,12 @@ declare module "module" {
* const relativeDirname = dirname(fileURLToPath(import.meta.url));
* ```
*/
var __dirname: string;
}
}
declare module "process" {
import { Level } from "pino";
global {
namespace NodeJS {
interface ProcessEnv {
@@ -31,26 +30,6 @@ declare module "process" {
* @see {@link https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production | The difference between development and production}
*/
readonly NODE_ENV?: "development" | "production";
/**
* Whether or not we are running on a CI server.
*/
readonly CI?: string;
/**
* The application log level.
*/
readonly AK_LOG_LEVEL?: Level;
/**
* The base URL of web server to run the tests against.
*
* Typically this is `http://localhost:9000`.
*
* @format url
*/
readonly AK_TEST_RUNNER_PAGE_URL?: string;
/**
* @todo Determine where this is used and if it is needed,
* give it a better name.