diff --git a/.changeset/chilly-pears-film.md b/.changeset/chilly-pears-film.md new file mode 100644 index 00000000000..a6c5dcd91e6 --- /dev/null +++ b/.changeset/chilly-pears-film.md @@ -0,0 +1,6 @@ +--- +"@clerk/clerk-js": patch +"@clerk/types": patch +--- + +Add element descriptors to `` component diff --git a/packages/clerk-js/bundlewatch.config.json b/packages/clerk-js/bundlewatch.config.json index bd7805ffc44..beaccfdac08 100644 --- a/packages/clerk-js/bundlewatch.config.json +++ b/packages/clerk-js/bundlewatch.config.json @@ -4,7 +4,7 @@ { "path": "./dist/clerk.browser.js", "maxSize": "70.16KB" }, { "path": "./dist/clerk.legacy.browser.js", "maxSize": "113KB" }, { "path": "./dist/clerk.headless*.js", "maxSize": "53.06KB" }, - { "path": "./dist/ui-common*.js", "maxSize": "108.4KB" }, + { "path": "./dist/ui-common*.js", "maxSize": "108.54KB" }, { "path": "./dist/vendors*.js", "maxSize": "40.2KB" }, { "path": "./dist/coinbase*.js", "maxSize": "38KB" }, { "path": "./dist/createorganization*.js", "maxSize": "5KB" }, diff --git a/packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx b/packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx index 6cefb696f91..95d2aaf2c05 100644 --- a/packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx +++ b/packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx @@ -5,7 +5,17 @@ import { lazy, useState } from 'react'; import useSWRMutation from 'swr/mutation'; import { useApiKeysContext, withCoreUserGuard } from '@/ui/contexts'; -import { Box, Button, Col, Flex, Flow, Icon, localizationKeys, useLocalizations } from '@/ui/customizables'; +import { + Box, + Button, + Col, + descriptors, + Flex, + Flow, + Icon, + localizationKeys, + useLocalizations, +} from '@/ui/customizables'; import { Action } from '@/ui/elements/Action'; import { useCardState, withCardStateProvider } from '@/ui/elements/contexts'; import { InputWithIcon } from '@/ui/elements/InputWithIcon'; @@ -81,6 +91,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr - + } @@ -103,6 +115,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr setSearch(e.target.value); setPage(1); }} + elementDescriptor={descriptors.apiKeysSearchInput} /> @@ -130,6 +144,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr rows={apiKeys} isLoading={isLoading} onRevoke={handleRevoke} + elementDescriptor={descriptors.apiKeysTable} /> {itemCount > (perPage ?? 5) && ( { aria-label={hasCopied ? 'Copied API key to clipboard' : 'Copy API key'} onClick={() => setEnabled(true)} focusRing={false} + elementDescriptor={descriptors.apiKeysCopyButton} > { })} focusRing={false} aria-label={'Show key'} + elementDescriptor={descriptors.apiKeysRevealButton} onClick={() => setRevealed(!revealed)} > void; + elementDescriptor?: ElementDescriptor; }) => { return ( ({ width: '100%', [mqu.sm]: { overflowX: 'auto', padding: t.space.$0x25 } })}> - ({ background: t.colors.$colorBackground })}> +
({ background: t.colors.$colorBackground })} + elementDescriptor={elementDescriptor} + > diff --git a/packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx b/packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx index 761be68c7e4..a5c89ca3790 100644 --- a/packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx +++ b/packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import { Box, Button, Col, Flex, FormLabel, localizationKeys, Text } from '@/ui/customizables'; +import { Box, Button, Col, descriptors, Flex, FormLabel, localizationKeys, Text } from '@/ui/customizables'; import { useActionContext } from '@/ui/elements/Action/ActionRoot'; import { Form } from '@/ui/elements/Form'; import { FormButtons } from '@/ui/elements/FormButtons'; @@ -97,14 +97,21 @@ export const CreateApiKeyForm = ({ onCreate, isSubmitting }: CreateApiKeyFormPro - + {showAdvanced && ( <> - + diff --git a/packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx b/packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx index 3cb67b93d49..3428a6e912b 100644 --- a/packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx +++ b/packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx @@ -1,6 +1,7 @@ import { useClerk } from '@clerk/shared/react'; import { useSWRConfig } from 'swr'; +import { descriptors } from '@/ui/customizables'; import { Card } from '@/ui/elements/Card'; import { Form } from '@/ui/elements/Form'; import { FormButtons } from '@/ui/elements/FormButtons'; @@ -37,6 +38,7 @@ export const RevokeAPIKeyConfirmationModal = ({ await clerk.apiKeys.revoke({ apiKeyID: apiKeyId }); const cacheKey = { key: 'api-keys', subject }; + void mutate(cacheKey); onClose(); }; @@ -79,7 +81,10 @@ export const RevokeAPIKeyConfirmationModal = ({ : {}, ]} > - + ({ textAlign: 'left', @@ -91,7 +96,10 @@ export const RevokeAPIKeyConfirmationModal = ({ headerSubtitle={localizationKeys('apiKeys.revokeConfirmation.formHint')} > - + diff --git a/packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts b/packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts index 757b99643c9..a034c2c3b2b 100644 --- a/packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts +++ b/packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts @@ -8,7 +8,6 @@ export const useApiKeys = ({ subject, perPage = 5 }: { subject: string; perPage? key: 'api-keys', subject, }; - const { data: apiKeys, isLoading, mutate } = useSWR(cacheKey, () => clerk.apiKeys.getAll({ subject })); const [search, setSearch] = useState(''); const filteredApiKeys = (apiKeys ?? []).filter(key => key.name.toLowerCase().includes(search.toLowerCase())); diff --git a/packages/clerk-js/src/ui/customizables/elementDescriptors.ts b/packages/clerk-js/src/ui/customizables/elementDescriptors.ts index 3e7f8804341..0b26ff5c4b3 100644 --- a/packages/clerk-js/src/ui/customizables/elementDescriptors.ts +++ b/packages/clerk-js/src/ui/customizables/elementDescriptors.ts @@ -333,6 +333,10 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([ 'tabListContainer', 'tableHead', + 'tableBody', + 'tableRow', + 'tableHeaderCell', + 'tableBodyCell', 'paginationButton', 'paginationButtonIcon', @@ -458,6 +462,23 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([ 'notificationBadge', 'buttonArrowIcon', 'spinner', + + 'apiKeys', + 'apiKeysHeader', + 'apiKeysSearchBox', + 'apiKeysSearchInput', + 'apiKeysAddButton', + 'apiKeysTable', + 'apiKeysCopyButton', + 'apiKeysRevealButton', + 'apiKeysCreateForm', + 'apiKeysCreateFormNameInput', + 'apiKeysCreateFormDescriptionInput', + 'apiKeysCreateFormExpirationInput', + 'apiKeysCreateFormSubmitButton', + 'apiKeysRevokeModal', + 'apiKeysRevokeModalInput', + 'apiKeysRevokeModalSubmitButton', ] as const).map(camelize) as (keyof ElementsConfig)[]; type TargettableClassname = `${typeof CLASS_PREFIX}${K}`; diff --git a/packages/clerk-js/src/ui/customizables/index.ts b/packages/clerk-js/src/ui/customizables/index.ts index ba2c0fed4a4..cecaf432abd 100644 --- a/packages/clerk-js/src/ui/customizables/index.ts +++ b/packages/clerk-js/src/ui/customizables/index.ts @@ -55,11 +55,15 @@ export const NotificationBadge = makeCustomizable(makeLocalizable(sanitizeDomPro }); export const Table = makeCustomizable(sanitizeDomProps(Primitives.Table), { defaultDescriptor: descriptors.table }); -export const Thead = makeCustomizable(sanitizeDomProps(Primitives.Thead)); -export const Tbody = makeCustomizable(sanitizeDomProps(Primitives.Tbody)); -export const Tr = makeCustomizable(sanitizeDomProps(Primitives.Tr)); -export const Th = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Th))); -export const Td = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Td))); +export const Thead = makeCustomizable(sanitizeDomProps(Primitives.Thead), { defaultDescriptor: descriptors.tableHead }); +export const Tbody = makeCustomizable(sanitizeDomProps(Primitives.Tbody), { defaultDescriptor: descriptors.tableBody }); +export const Tr = makeCustomizable(sanitizeDomProps(Primitives.Tr), { defaultDescriptor: descriptors.tableRow }); +export const Th = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Th)), { + defaultDescriptor: descriptors.tableHeaderCell, +}); +export const Td = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Td)), { + defaultDescriptor: descriptors.tableBodyCell, +}); export const Dl = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Dl))); export const Dd = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Dd))); diff --git a/packages/types/src/appearance.ts b/packages/types/src/appearance.ts index a8756c21b3a..f9101dc5bb4 100644 --- a/packages/types/src/appearance.ts +++ b/packages/types/src/appearance.ts @@ -459,6 +459,10 @@ export type ElementsConfig = { tabListContainer: WithOptions; tableHead: WithOptions; + tableBody: WithOptions; + tableRow: WithOptions; + tableHeaderCell: WithOptions; + tableBodyCell: WithOptions; paginationButton: WithOptions; paginationButtonIcon: WithOptions; @@ -586,6 +590,23 @@ export type ElementsConfig = { notificationBadge: WithOptions; buttonArrowIcon: WithOptions; spinner: WithOptions; + + apiKeys: WithOptions; + apiKeysHeader: WithOptions; + apiKeysSearchBox: WithOptions; + apiKeysSearchInput: WithOptions; + apiKeysAddButton: WithOptions; + apiKeysTable: WithOptions; + apiKeysCopyButton: WithOptions; + apiKeysRevealButton: WithOptions; + apiKeysCreateForm: WithOptions; + apiKeysCreateFormNameInput: WithOptions; + apiKeysCreateFormDescriptionInput: WithOptions; + apiKeysCreateFormExpirationInput: WithOptions; + apiKeysCreateFormSubmitButton: WithOptions; + apiKeysRevokeModal: WithOptions; + apiKeysRevokeModalInput: WithOptions; + apiKeysRevokeModalSubmitButton: WithOptions; }; export type Elements = {
Name