-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from twilio/typescript-support
support typescript
- Loading branch information
Showing
9 changed files
with
151 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "{{name}}", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"bootstrap": "flex-check-start", | ||
"postinstall": "npm run bootstrap", | ||
"prestart": "npm run bootstrap", | ||
"start": "craco start", | ||
"build": "craco build", | ||
"test": "craco test --env=jsdom", | ||
"eject": "craco eject" | ||
}, | ||
"devDependencies": { | ||
"@twilio/flex-ui": "{{flexSdkVersion}}" | ||
}, | ||
"dependencies": { | ||
"@craco/craco": "^5.0.2", | ||
"@types/jest": "^24.0.12", | ||
"@types/node": "^12.0.0", | ||
"@types/react": "^16.8.16", | ||
"@types/react-dom": "^16.8.4", | ||
"core-js": "^2.6.5", | ||
"craco-config-flex-plugin": "{{cracoConfigVersion}}", | ||
"flex-plugin": "{{flexPluginVersion}}", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"react-scripts": "^3.0.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/create-flex-plugin/templates/ts/src/DemoPlugin.tsx
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,29 @@ | ||
import React from 'react'; | ||
import * as Flex from '@twilio/flex-ui'; | ||
import { FlexPlugin } from 'flex-plugin'; | ||
|
||
import CustomTaskListComponent from './components/CustomTaskListComponent'; | ||
|
||
const PLUGIN_NAME = '{{pluginClassName}}'; | ||
|
||
export default class {{pluginClassName}} extends FlexPlugin { | ||
constructor() { | ||
super(PLUGIN_NAME); | ||
} | ||
|
||
/** | ||
* This code is run when your plugin is being started | ||
* Use this to modify any UI components or attach to the actions framework | ||
* | ||
* @param flex { typeof import('@twilio/flex-ui') } | ||
* @param manager { import('@twilio/flex-ui').Manager } | ||
*/ | ||
init(flex: typeof Flex, manager: Flex.Manager) { | ||
flex.AgentDesktopView.Panel1.Content.add( | ||
<CustomTaskListComponent key="demo-component" />, | ||
{ | ||
sortOrder: -1, | ||
} | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/create-flex-plugin/templates/ts/src/components/CustomTaskListComponent.tsx
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,16 @@ | ||
import React from 'react'; | ||
|
||
const taskListStyles = { | ||
padding: '10px', | ||
margin: '0px', | ||
color: '#fff', | ||
background: '#000', | ||
}; | ||
|
||
const CustomTaskListComponent = () => { | ||
return ( | ||
<div style={taskListStyles}>This is a demo component</div> | ||
); | ||
}; | ||
|
||
export default CustomTaskListComponent; |
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,4 @@ | ||
import * as FlexPlugin from 'flex-plugin'; | ||
import {{pluginClassName}} from './{{pluginClassName}}'; | ||
|
||
FlexPlugin.loadPlugin({{pluginClassName}}); |
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,36 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "src", | ||
"rootDir": ".", | ||
"outDir": "build", | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true, | ||
"jsx": "preserve", | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false | ||
}, | ||
"include": [ | ||
"./src/**/*" | ||
], | ||
"exclude": [ | ||
"./**/*.test.ts", | ||
"./**/*.test.tsx", | ||
"./**/__mocks__/*.ts", | ||
"./**/__mocks__/*.tsx" | ||
] | ||
} |
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,8 @@ | ||
{ | ||
"extends": ["../../tslint.json"] | ||
"extends": ["../../tslint.json"], | ||
"linterOptions": { | ||
"exclude": [ | ||
"templates/**/*" | ||
] | ||
} | ||
} |