-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into id-367-get-user-registration-from-sam
- Loading branch information
Showing
79 changed files
with
1,673 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Publish Storybook to Chromatic | ||
|
||
on: | ||
push: | ||
tags-ignore: | ||
- v0.* | ||
|
||
jobs: | ||
chromatic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install dependencies | ||
run: yarn install --immutable | ||
|
||
- name: Build packages | ||
run: yarn build-packages | ||
|
||
- name: Run Chromatic | ||
uses: chromaui/action@latest | ||
with: | ||
projectToken: ${{ secrets.CHROMATIC_PUBLISH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import 'src/style.css'; | ||
|
||
import type { Preview } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
|
Binary file added
BIN
+20 KB
.yarn/cache/@storybook-addon-actions-npm-8.0.0-75a5805655-c24e07def8.zip
Binary file not shown.
Binary file added
BIN
+48.2 KB
.yarn/cache/@storybook-core-events-npm-8.0.0-da75541082-5c58add81b.zip
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// ESLint thinks @terra-ui-packages/test-utils should be listed in dependencies instead of devDependencies. | ||
// TODO: Fix this in ESLint configuration. | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { getJestConfig } from '@terra-ui-packages/test-utils'; | ||
|
||
export default getJestConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@terra-ui-packages/analysis", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"build": "vite build --emptyOutDir", | ||
"dev": "vite build --mode=development --watch", | ||
"test": "jest" | ||
}, | ||
"type": "module", | ||
"module": "./lib/es/index.js", | ||
"main": "./lib/cjs/index.cjs", | ||
"types": "./lib/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./lib/es/index.js", | ||
"require": "./lib/cjs/index.cjs", | ||
"types": "./lib/types/index.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
"lib/cjs/**", | ||
"lib/es/**", | ||
"lib/types/**/*.d.ts" | ||
], | ||
"dependencies": { | ||
"@terra-ui-packages/components": "^0.0.6", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@terra-ui-packages/build-utils": "^1.0.0", | ||
"@terra-ui-packages/test-utils": "*", | ||
"@testing-library/dom": "^9.3.1", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/user-event": "^14.4.3", | ||
"@types/jest": "^28.1.8", | ||
"@types/lodash": "^4.14.184", | ||
"@types/react": "^18.2.15", | ||
"@types/testing-library__jest-dom": "^5.14.9", | ||
"jest": "^27.4.3", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"typescript": "~5.1.6", | ||
"vite": "^4.5.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"noImplicitAny": true, | ||
"outDir": "lib/types", | ||
"rootDir": "src" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { viteConfig as defineBaseConfig } from '@terra-ui-packages/build-utils'; | ||
|
||
export default defineBaseConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// ESLint thinks @terra-ui-packages/test-utils should be listed in dependencies instead of devDependencies. | ||
// TODO: Fix this in ESLint configuration. | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { getJestConfig } from '@terra-ui-packages/test-utils'; | ||
|
||
export default getJestConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@terra-ui-packages/notifications", | ||
"version": "1.0.1", | ||
"scripts": { | ||
"build": "vite build --emptyOutDir", | ||
"dev": "vite build --mode=development --watch", | ||
"test": "jest" | ||
}, | ||
"type": "module", | ||
"module": "./lib/es/index.js", | ||
"main": "./lib/cjs/index.cjs", | ||
"types": "./lib/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./lib/es/index.js", | ||
"require": "./lib/cjs/index.cjs", | ||
"types": "./lib/types/index.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
"lib/cjs/**", | ||
"lib/es/**", | ||
"lib/types/**/*.d.ts" | ||
], | ||
"dependencies": { | ||
"@terra-ui-packages/components": "^0.0.6", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"@terra-ui-packages/build-utils": "^1.0.0", | ||
"@terra-ui-packages/test-utils": "*", | ||
"@testing-library/dom": "^9.3.1", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/user-event": "^14.4.3", | ||
"@types/jest": "^28.1.8", | ||
"@types/lodash": "^4.14.184", | ||
"@types/react": "^18.2.15", | ||
"@types/testing-library__jest-dom": "^5.14.9", | ||
"jest": "^27.4.3", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"typescript": "~5.1.6", | ||
"vite": "^4.5.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useNotifications'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ErrorBoundary } from '@terra-ui-packages/components'; | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { NotificationsContract, NotificationsProvider, text, useNotificationsFromContext } from './useNotifications'; | ||
|
||
describe('useNotificationsFromContext', () => { | ||
it('gets notifications provider from context', () => { | ||
// Arrange | ||
const onRenderWithReporter = jest.fn(); | ||
|
||
const TestComponent = () => { | ||
const reporter = useNotificationsFromContext(); | ||
onRenderWithReporter(reporter); | ||
return null; | ||
}; | ||
|
||
const reporter: NotificationsContract = { | ||
notify: jest.fn(), | ||
}; | ||
|
||
// Act | ||
render( | ||
<NotificationsProvider notifications={reporter}> | ||
<TestComponent /> | ||
</NotificationsProvider> | ||
); | ||
|
||
// Assert | ||
expect(onRenderWithReporter).toHaveBeenCalledWith(expect.objectContaining(reporter)); | ||
}); | ||
|
||
it('throw an error if no notifications provider is provided', () => { | ||
// Arrange | ||
const onRenderError = jest.fn(); | ||
|
||
const TestComponent = () => { | ||
useNotificationsFromContext(); | ||
return null; | ||
}; | ||
|
||
// Prevent React from logging the error. | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
|
||
// Act | ||
render( | ||
<ErrorBoundary onError={onRenderError}> | ||
<TestComponent /> | ||
</ErrorBoundary> | ||
); | ||
|
||
// Assert | ||
expect(onRenderError).toHaveBeenCalledWith(new Error(text.error.noProvider)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { createContext, createElement, PropsWithChildren, ReactNode, useContext } from 'react'; | ||
|
||
export type NotificationType = 'error' | 'warn' | 'info' | 'success' | 'welcome'; | ||
export interface NotificationOptions { | ||
/** | ||
* string, Error(unknown), or json object to be displayed in detail section | ||
*/ | ||
detail?: unknown; | ||
} | ||
|
||
export interface NotificationsContract { | ||
notify: (type: NotificationType, title: string, options?: NotificationOptions) => void; | ||
} | ||
const NotificationsContext = createContext<NotificationsContract | null>(null); | ||
|
||
export type NotificationsProviderProps = PropsWithChildren<{ | ||
notifications: NotificationsContract; | ||
}>; | ||
|
||
export const text = { | ||
error: { | ||
noProvider: | ||
'No NotificationsProvider provided. Components (or hooks within them) using useNotificationsFromContext must be descendants of NotificationsProvider.', | ||
}, | ||
}; | ||
|
||
/** Provides notifications to descendents via React Context. */ | ||
export const NotificationsProvider = (props: NotificationsProviderProps): ReactNode => { | ||
const { children, notifications } = props; | ||
return createElement(NotificationsContext.Provider, { value: notifications }, children); | ||
}; | ||
/** Gets the current NotificationsProvider from React context. */ | ||
export const useNotificationsFromContext = (): NotificationsContract => { | ||
const notifier = useContext(NotificationsContext); | ||
if (!notifier) { | ||
throw new Error(text.error.noProvider); | ||
} | ||
return notifier; | ||
}; |
Oops, something went wrong.