playroom 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +1 -1
- package/.github/workflows/release.yml +2 -1
- package/.prettierignore +1 -0
- package/@types/babel__standalone.d.ts +1 -1
- package/CHANGELOG.md +7 -0
- package/README.md +3 -1
- package/cypress/e2e/smoke.cy.js +8 -0
- package/cypress/e2e/snippets.cy.js +2 -2
- package/cypress/e2e/toolbar.cy.js +2 -2
- package/cypress/projects/basic/components.js +0 -1
- package/cypress/projects/basic/snippets.js +5 -0
- package/cypress/projects/themed/components.js +0 -1
- package/cypress/projects/typescript/components/Bar.tsx +13 -0
- package/cypress/projects/typescript/components/Foo.tsx +13 -0
- package/cypress/projects/typescript/components/styles.ts +4 -0
- package/cypress/projects/typescript/components.ts +2 -0
- package/cypress/projects/typescript/playroom.config.js +33 -0
- package/cypress/projects/typescript/snippets.ts +22 -0
- package/cypress/projects/typescript/tsconfig.json +18 -0
- package/cypress/support/utils.js +13 -15
- package/cypress/tsconfig.json +9 -0
- package/lib/defaultModules/FrameComponent.js +1 -3
- package/lib/makeDefaultWebpackConfig.js +4 -1
- package/lib/makeWebpackConfig.js +8 -2
- package/package.json +19 -12
- package/src/Playroom/Button/Button.tsx +1 -1
- package/src/Playroom/CatchErrors/CatchErrors.tsx +1 -1
- package/src/Playroom/CodeEditor/CodeEditor.tsx +7 -3
- package/src/Playroom/CodeEditor/keymaps/complete.ts +1 -1
- package/src/Playroom/CodeEditor/keymaps/cursors.ts +2 -2
- package/src/Playroom/CodeEditor/keymaps/lines.ts +2 -3
- package/src/Playroom/CodeEditor/keymaps/types.ts +1 -1
- package/src/Playroom/CodeEditor/keymaps/wrap.ts +3 -2
- package/src/Playroom/Divider/Divider.tsx +0 -2
- package/src/Playroom/Frame.tsx +2 -1
- package/src/Playroom/Frames/Frames.tsx +2 -2
- package/src/Playroom/Frames/Iframe.tsx +3 -3
- package/src/Playroom/FramesPanel/CheckmarkSvg.tsx +1 -1
- package/src/Playroom/FramesPanel/FramesPanel.tsx +1 -1
- package/src/Playroom/Heading/Heading.tsx +1 -1
- package/src/Playroom/Inline/Inline.tsx +1 -1
- package/src/Playroom/Logo/Logo.tsx +0 -2
- package/src/Playroom/Playroom.tsx +7 -3
- package/src/Playroom/Preview.tsx +1 -1
- package/src/Playroom/PreviewPanel/CopyButton.tsx +1 -1
- package/src/Playroom/PreviewPanel/PreviewPanel.tsx +1 -1
- package/src/Playroom/PreviewPanel/ThemeSelector.tsx +1 -1
- package/src/Playroom/SettingsPanel/SettingsPanel.tsx +3 -3
- package/src/Playroom/Snippets/SearchField/SearchField.tsx +1 -1
- package/src/Playroom/Snippets/Snippets.tsx +4 -3
- package/src/Playroom/SplashScreen/SplashScreen.tsx +1 -1
- package/src/Playroom/Stack/Stack.tsx +1 -1
- package/src/Playroom/StatusMessage/StatusMessage.tsx +1 -7
- package/src/Playroom/Strong/Strong.tsx +1 -1
- package/src/Playroom/Text/Text.tsx +1 -1
- package/src/Playroom/Toolbar/Toolbar.tsx +2 -2
- package/src/Playroom/ToolbarItem/ToolbarItem.tsx +1 -1
- package/src/Playroom/ToolbarPanel/ToolbarPanel.tsx +1 -1
- package/src/Playroom/WindowPortal/index.tsx +1 -1
- package/src/Playroom/icons/AddIcon.tsx +1 -1
- package/src/Playroom/icons/ChevronIcon.tsx +1 -1
- package/src/Playroom/icons/ColorModeDarkIcon.tsx +0 -2
- package/src/Playroom/icons/ColorModeLightIcon.tsx +0 -2
- package/src/Playroom/icons/ColorModeSystemIcon.tsx +0 -2
- package/src/Playroom/icons/DismissIcon.tsx +0 -2
- package/src/Playroom/icons/EditorBottomIcon.tsx +1 -1
- package/src/Playroom/icons/EditorRightIcon.tsx +1 -1
- package/src/Playroom/icons/EditorUndockedIcon.tsx +1 -1
- package/src/Playroom/icons/FramesIcon.tsx +1 -1
- package/src/Playroom/icons/PlayIcon.tsx +0 -2
- package/src/Playroom/icons/SettingsIcon.tsx +0 -2
- package/src/Playroom/icons/ShareIcon.tsx +0 -2
- package/src/Playroom/icons/ThemesIcon.tsx +1 -1
- package/src/Playroom/icons/TickIcon.tsx +0 -2
- package/src/Playroom/icons/WidthsIcon.tsx +1 -1
- package/src/StoreContext/StoreContext.tsx +6 -5
- package/src/frame.js +0 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +0 -2
- package/src/preview.js +0 -1
- package/src/utils/componentsToHints.ts +1 -1
- package/src/utils/cursor.ts +1 -1
- package/src/utils/formatting.ts +1 -1
- package/src/utils/params.ts +1 -1
- package/tsconfig.json +10 -5
- package/cypress/.eslintrc +0 -12
- /package/{cypress.config.ts → cypress.config.mjs} +0 -0
package/.babelrc
CHANGED
|
@@ -17,9 +17,10 @@ jobs:
|
|
|
17
17
|
with:
|
|
18
18
|
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
|
19
19
|
fetch-depth: 0
|
|
20
|
+
token: ${{ secrets.SEEK_OSS_CI_GITHUB_TOKEN }}
|
|
20
21
|
|
|
21
22
|
- name: Set up pnpm
|
|
22
|
-
uses: pnpm/action-setup@v2
|
|
23
|
+
uses: pnpm/action-setup@v2
|
|
23
24
|
|
|
24
25
|
- name: Set up Node.js
|
|
25
26
|
uses: actions/setup-node@v3
|
package/.prettierignore
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<img src="images/logo.png?raw=true#gh-light-mode-only" alt="Playroom" title="Playroom" width="292" height="50" />
|
|
2
2
|
<img src="images/logo-inverted.png?raw=true#gh-dark-mode-only" alt="Playroom" title="Playroom" width="292" height="50" />
|
|
3
3
|
|
|
4
|
-
[](https://www.npmjs.com/package/playroom) [](https://www.npmjs.com/package/playroom) [](https://github.com/seek-oss/playroom/actions?query=workflow%3AValidate+branch%3Amaster)
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -32,6 +32,8 @@ Playroom allows you to create a zero-install code-oriented design environment, b
|
|
|
32
32
|
|
|
33
33
|
[Shopify Polaris](https://polaris.shopify.com/sandbox?code=N4Igxg9gJgpiBcIA8BhAhgJygHQHYAJ8BnGSXKTATwDEIIAXGDAQTHoEsJciBeYAbWBlGuevHwByACLsiAW1lEJAXwC6yvIQAOGdnKq0GTVhy58hXEWMkBRAB5aIGevgBKMR85UbcAPk34qJhQAHQAEjBosBj4aGyc3HyC%2BMIwouISACoMaAA2%2BADKeTBK%2BGrK%2BBz0uTA82CBFNUT1-gSEgQAKEI4AbkwB7bHxfXwAZnkkPoOEcRw9aPROfAPTSABCAK70iwRQsmC5EEQbGDD4Wrlo7H4r0-gAauwwAO6Fxc1td0gA9JvbXK07lNplwUIcSHwABQASnwPF8%2BGAymBhEBqxMCQAMrIXOxGHJeAILKI0tYJABxDBHIhvJoqAA0iNS6UkADkYC5GiUVOp8N80YQfl1ekw0T90FhwpFomKJaECqRTDdPoFMjA7PQUJYrrhRbd8ABNCAbFJoAgbEjEd74U6eeg0xbEGBna6jJz6JWxABGxpclGNMTAFsWciYREAmAT6pzRGletAkKD4LgpXSMXRoYgbMAAC1iNKI1ogfRiHFDjK9lBS2bNutyjKc%2BAr%2BqI9DQo1GIRWPzVGq1oh1era4uCIQV8QBASCkrHnqqNTqIGyrfyXJpa1OaAA1lAIM9cC0u%2B4iAGwDBsS39adjydT6y0KHzERrgBzDaXDAZAs1CSMi4nPKfu83j6niMAEkk%2BqEMAkHtF%2BJQZAA8lgYY-jBMxyMaLISAAqgUUgACQAAwhIRhGoSqdwnLkGS2k49rfNGKH0jByjMRR7TQexgxwUQGTuPQJzcORdyDPemFkgAtLhBEAEwAKzEaRwkiYQVE0R4dFEN8pwCRgQlsSprH6uol5pNEACS%2BJQqBciwvCiIwWQLaIjxjJiRsoiMlRFQ8PgNkANwwTpgn4JCaGBEeJ5njiISWWB4WqRguR8N5CVDKeRBPl67C5HilCYmgXowMlwAAAaPC8tIlPgboxPhwA8copUoip%2BACq1SAFK2YCbu1rWBF1cSbrF%2BI1TluS%2BA17zKD8g09SNYF9R1c3DXFciTe5ogzd8K0LetaWzd1vXhT8kU3tFLZ7UthDQoF7HIvq-KTt8cqjoqCSyiOM4JJUeLzvUUiRMMCwwImtHOM0ICZl6UAbKD7VIOe9BLYjMVrb4HRoP6WxED8SNXfqqOXejS55FVa6Vig1a4LWeNo-iCPfEjYovV970TkOr3fcmc61PUrJGAeKpID2mratcg53Jk2ZnDxNoaRDsSnLE8w5YVNRJrguSVuwoz4NjMQtk4Lo0jzMuFNm3S65Q%2BoXGaSYxNm7DPjLGCdsL3yi32rYSxgLNc%2BzyrDlgvggPSID0DLoZEAg-AgIcYDFPAaQgKo4fPOwUCRzH8D8OoQA)
|
|
34
34
|
|
|
35
|
+
[Agriculture Design System](https://design-system.agriculture.gov.au/playroom/#?code=N4Igxg9gJgpiBcIA8AhCAPABFAhgJwGsA%2BAHQDtNMkAJGHWPTAIxzAIHM8IBXMqAXhIgm0AJ4BBADYAXIZkkR2EfsCQAZRREwB6IgF9MACzpQAlmXaCQAUXQAHCHmmYAyjDwA3U2Bhzd5SiQAWRxzADkcDwDKTFNpGABbAGcVAG1geRwmGEl4TCFqCATfEAAaIzwYADM8oW05PQBdPWjKJJhIPnxRAEl45LSMySyc2pAXU3YKcyFymD5rSUT56TykcQ8caXwezp0iTCaWin3yJG00dFIyJAAFHHYYAGEIMni3zBwUoQTQsiFroFblx2oCYkhDABGIj3R5GEzmdjnKFgwJ2VExDSVBKxOxJbg4qAQBSMJJxT7FaTlTrtMDxaTcRj0Ux2UxJMCIzA5OIAOkwtxySzeMCSAEduDBPrITjFPngwNwuUtTFV5lByps8KZuEkuWRTDiyK85srVXxMPqmIY%2BQBFbhs8WS1iZDn6nBK3mtGIAeXlpkwmu1urIWwgjswdnmW1MTB1XOcvymbOwybs%2BAZWpWmASr3iSXKIfZMAzXsoWrMCskcYSOr5PWFj1JPiWWrFEql8km3GGmH6DkYORgKrVfIAaiLpDHuwTSwHidxpGmqdhiY4uYq8AvNziaTBxVtypIY%2B4tAArHXSLTDV2md2XpyOcqmKCzwNx%2B-3z7CzBk5w4SkWmykh8uI8x0BQWzYPaKb-nyTx4F8nyduw3bujgs44N%2BOBHvuOLXuYt58gAqs4RIkpguHlJwkTPu6MCKlA0Himy5Q5ksSSTr4MoxPhboriSfIAGI6j4LrVqY5R2IY%2BDFgh2bEhOpiSh%2Ba70eUVQEbGSSzrxt6dtkXA8l65zosZpncZQLg6pGfBsu0mCqtw7C3s4eCGK8Cq6omIZKkOZpQJ8OHcLBmBBI4TD%2BvRbI5gFMDoLOnSbJIR66l4HjuHJg7DnwfJhN2ww4ulkgOZpcZHgZEB8iEHRRrqSxaO0CSlAlry0vSjI-uS-7Fri%2BKFTk1JFDFWj9tIk6frhuX5f%2B%2BknrOZDTdSjL4rqd6MqyurFuU00JJAeCRowCgiE4yaUrWmBSKYuGBVdwUJLOSTQNhIrZs9%2BL0DgfK3NJ7TJXGv4Uj15UnpgC4WtNEaONsmCOCGlR1v8Fkes4Sx0jqT6sN2yY9R486LpBMCPMufZrrDMlciCCPxHgjE4sWs6-OxwW4A53WrWAX7xL1BIRlqCTJuYrPcByWl8lZSQ2WYST2Y9uDsQzxZxsxqXdnYC5bJKiXYSlVXhf6nQoZKqMMptROvdL7oaZaOo6cLJtfYKKwiuGfZxox-pFZ8dtrjte0HUZ3EmWC5zAhAoJnNosLPLmKzXKgGDYPgxDREggkQBA1PMKwHBcLwAhCCIUASDIALGSGHhyreAC0wzZJIVhVOn1Ol0j6jmAQahstKsqyu5WoAF65ths6UEeZAECkwCpCPMQZIYlQ1PkIAAMSzJkddjIUxQNM1SOynPC9jKvZTr6MS8ACruMkX4BZ0ZiTq1O8z5QB-VEfa%2B12fQjAqYmxgKIkMjz-yfnvWeFQ35L2PoeEYuQl7iEwJUbWACFAWE7OPXscQlggJ7jEZos5-CB20OXYO2g04Z3cHHC4GBrggD0EAA)
|
|
36
|
+
|
|
35
37
|
Send us a PR if you'd like to be in this list!
|
|
36
38
|
|
|
37
39
|
## Getting Started
|
package/cypress/e2e/smoke.cy.js
CHANGED
|
@@ -17,4 +17,12 @@ describe('Smoke', () => {
|
|
|
17
17
|
|
|
18
18
|
assertPreviewContains('Foo\nFoo\nBar');
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
it('preview mode works with TypeScript components', () => {
|
|
22
|
+
cy.visit(
|
|
23
|
+
'http://localhost:9002/preview#?code=N4Igxg9gJgpiBcIA8AxCEB8r1YEIEMAnAei2LUyXJxAF8g'
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
assertPreviewContains('Foo\nFoo\nBar');
|
|
27
|
+
});
|
|
20
28
|
});
|
|
@@ -27,7 +27,7 @@ describe('Snippets', () => {
|
|
|
27
27
|
assertCodePaneLineCount(8);
|
|
28
28
|
|
|
29
29
|
// Browse snippetlist
|
|
30
|
-
assertSnippetCount(
|
|
30
|
+
assertSnippetCount(5);
|
|
31
31
|
mouseOverSnippet(0);
|
|
32
32
|
assertFirstFrameContains('Initial code\nFoo\nFoo');
|
|
33
33
|
mouseOverSnippet(1);
|
|
@@ -78,7 +78,7 @@ describe('Snippets', () => {
|
|
|
78
78
|
assertCodePaneLineCount(8);
|
|
79
79
|
|
|
80
80
|
// Browse snippetlist
|
|
81
|
-
assertSnippetCount(
|
|
81
|
+
assertSnippetCount(5);
|
|
82
82
|
filterSnippets('{downarrow}');
|
|
83
83
|
assertFirstFrameContains('Initial code\nFoo\nFoo');
|
|
84
84
|
filterSnippets('{downarrow}');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { parent } from './styles';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
color: 'red' | 'blue' | 'black';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Bar: React.FC<Props> = ({ color = 'black', children }) => (
|
|
10
|
+
<div style={{ color }}>
|
|
11
|
+
Bar{children ? <div style={parent}>{children}</div> : null}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { parent } from './styles';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
color: 'red' | 'blue' | 'black';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Foo: React.FC<Props> = ({ color = 'black', children }) => (
|
|
10
|
+
<div style={{ color }}>
|
|
11
|
+
Foo{children ? <div style={parent}>{children}</div> : null}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
components: './components.ts',
|
|
3
|
+
snippets: './snippets.ts',
|
|
4
|
+
outputPath: './dist',
|
|
5
|
+
openBrowser: false,
|
|
6
|
+
storageKey: 'playroom-example-typescript',
|
|
7
|
+
webpackConfig: () => ({
|
|
8
|
+
module: {
|
|
9
|
+
rules: [
|
|
10
|
+
{
|
|
11
|
+
test: /\.tsx?$/,
|
|
12
|
+
exclude: /node_modules/,
|
|
13
|
+
use: [
|
|
14
|
+
{
|
|
15
|
+
loader: require.resolve('babel-loader'),
|
|
16
|
+
options: {
|
|
17
|
+
babelrc: false,
|
|
18
|
+
presets: [
|
|
19
|
+
require.resolve('@babel/preset-env'),
|
|
20
|
+
[
|
|
21
|
+
require.resolve('@babel/preset-react'),
|
|
22
|
+
{ runtime: 'automatic' },
|
|
23
|
+
],
|
|
24
|
+
require.resolve('@babel/preset-typescript'),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
group: 'Foo',
|
|
4
|
+
name: 'Default',
|
|
5
|
+
code: '<Foo>Foo</Foo>',
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
group: 'Foo',
|
|
9
|
+
name: 'Red',
|
|
10
|
+
code: '<Foo color="red">Red Foo</Foo>',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
group: 'Bar',
|
|
14
|
+
name: 'Default',
|
|
15
|
+
code: '<Bar>Bar</Bar>',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
group: 'Bar',
|
|
19
|
+
name: 'Blue',
|
|
20
|
+
code: '<Bar color="blue">Blue Bar</Bar>',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"noEmit": true,
|
|
4
|
+
"skipLibCheck": true,
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"module": "es2022",
|
|
7
|
+
"allowImportingTsExtensions": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"lib": ["dom", "es2022"],
|
|
16
|
+
"target": "es2022"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/cypress/support/utils.js
CHANGED
|
@@ -58,12 +58,11 @@ export const gotoPreview = () => {
|
|
|
58
58
|
export const toggleSnippets = () =>
|
|
59
59
|
cy.get('[data-testid="toggleSnippets"]').click();
|
|
60
60
|
|
|
61
|
-
export const filterSnippets = (search) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.wait(200);
|
|
61
|
+
export const filterSnippets = (search) => {
|
|
62
|
+
cy.get('[data-testid="filterSnippets"]').type(search, { force: true });
|
|
63
|
+
// eslint-disable-next-line @finsit/cypress/no-unnecessary-waiting
|
|
64
|
+
cy.wait(200);
|
|
65
|
+
};
|
|
67
66
|
|
|
68
67
|
export const assertSnippetsListIsVisible = () =>
|
|
69
68
|
cy.get('[data-testid="snippets"]').should('be.visible');
|
|
@@ -82,7 +81,7 @@ export const assertSnippetCount = (count) =>
|
|
|
82
81
|
|
|
83
82
|
export const assertFirstFrameContains = (text) => {
|
|
84
83
|
getFirstFrame().then(($el) =>
|
|
85
|
-
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
84
|
+
// eslint-disable-next-line @finsit/cypress/no-unnecessary-waiting
|
|
86
85
|
cy
|
|
87
86
|
.wrap($el.contents().find('body'))
|
|
88
87
|
.wait(WAIT_FOR_FRAME_TO_RENDER)
|
|
@@ -120,14 +119,13 @@ export const selectLines = (numLines, direction = 'down') => {
|
|
|
120
119
|
export const assertCodePaneContains = (text) => {
|
|
121
120
|
getCodeEditor().within(() => {
|
|
122
121
|
const lines = [];
|
|
123
|
-
cy.get('.CodeMirror-line')
|
|
124
|
-
|
|
125
|
-
.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
122
|
+
cy.get('.CodeMirror-line').each(($el) => lines.push($el.text()));
|
|
123
|
+
cy.then(() => {
|
|
124
|
+
const code = lines.join('\n');
|
|
125
|
+
// removes code mirrors invisible last line character placeholder
|
|
126
|
+
// which is inserted to preserve prettiers new line at end of string.
|
|
127
|
+
expect(code.replace(/[\u200b]$/, '')).to.eq(text);
|
|
128
|
+
});
|
|
131
129
|
});
|
|
132
130
|
};
|
|
133
131
|
|
package/lib/makeWebpackConfig.js
CHANGED
|
@@ -90,7 +90,10 @@ module.exports = async (playroomConfig, options) => {
|
|
|
90
90
|
require.resolve('@babel/preset-env'),
|
|
91
91
|
{ shippedProposals: true },
|
|
92
92
|
],
|
|
93
|
-
|
|
93
|
+
[
|
|
94
|
+
require.resolve('@babel/preset-react'),
|
|
95
|
+
{ runtime: 'automatic' },
|
|
96
|
+
],
|
|
94
97
|
require.resolve('@babel/preset-typescript'),
|
|
95
98
|
],
|
|
96
99
|
},
|
|
@@ -109,7 +112,10 @@ module.exports = async (playroomConfig, options) => {
|
|
|
109
112
|
require.resolve('@babel/preset-env'),
|
|
110
113
|
{ shippedProposals: true },
|
|
111
114
|
],
|
|
112
|
-
|
|
115
|
+
[
|
|
116
|
+
require.resolve('@babel/preset-react'),
|
|
117
|
+
{ runtime: 'automatic' },
|
|
118
|
+
],
|
|
113
119
|
],
|
|
114
120
|
},
|
|
115
121
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "playroom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Design with code, powered by your own component library",
|
|
5
5
|
"main": "utils/index.js",
|
|
6
6
|
"types": "utils/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"react-use": "^17.4.0",
|
|
76
76
|
"read-pkg-up": "^7.0.1",
|
|
77
77
|
"scope-eval": "^1.0.0",
|
|
78
|
-
"typescript": "
|
|
78
|
+
"typescript": ">=5.0.0",
|
|
79
79
|
"use-debounce": "^9.0.2",
|
|
80
80
|
"webpack": "^5.75.0",
|
|
81
81
|
"webpack-dev-server": "^4.11.1",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"@types/jest": "^29.2.4",
|
|
89
89
|
"concurrently": "^7.6.0",
|
|
90
90
|
"cypress": "^12.0.2",
|
|
91
|
-
"eslint": "^8.
|
|
92
|
-
"eslint-config-seek": "^
|
|
91
|
+
"eslint": "^8.44.0",
|
|
92
|
+
"eslint-config-seek": "^11.3.1",
|
|
93
93
|
"husky": "^8.0.2",
|
|
94
94
|
"jest": "^29.3.1",
|
|
95
95
|
"lint-staged": "^13.1.0",
|
|
@@ -100,16 +100,16 @@
|
|
|
100
100
|
"surge": "^0.23.1"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"react": "^
|
|
104
|
-
"react-dom": "^
|
|
103
|
+
"react": "^17 || ^18",
|
|
104
|
+
"react-dom": "^17 || ^18"
|
|
105
105
|
},
|
|
106
106
|
"packageManager": "pnpm@7.18.1",
|
|
107
107
|
"volta": {
|
|
108
108
|
"node": "16.13.0"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
|
-
"cypress": "start-server-and-test build-and-serve:all '9000|9001' 'cypress run'",
|
|
112
|
-
"cypress:dev": "start-server-and-test start:all '9000|9001' 'cypress open --browser chrome --e2e'",
|
|
111
|
+
"cypress": "start-server-and-test build-and-serve:all '9000|9001|9002' 'cypress run'",
|
|
112
|
+
"cypress:dev": "start-server-and-test start:all '9000|9001|9002' 'cypress open --browser chrome --e2e'",
|
|
113
113
|
"cypress:verify": "cypress verify",
|
|
114
114
|
"start:basic": "./bin/cli.js start --config cypress/projects/basic/playroom.config.js",
|
|
115
115
|
"build:basic": "./bin/cli.js build --config cypress/projects/basic/playroom.config.js",
|
|
@@ -117,11 +117,18 @@
|
|
|
117
117
|
"start:themed": "./bin/cli.js start --config cypress/projects/themed/playroom.config.js",
|
|
118
118
|
"build:themed": "./bin/cli.js build --config cypress/projects/themed/playroom.config.js",
|
|
119
119
|
"serve:themed": "PORT=9001 serve --config ../serve.json --no-request-logging cypress/projects/themed/dist",
|
|
120
|
-
"start:
|
|
121
|
-
"build:
|
|
122
|
-
"serve:
|
|
120
|
+
"start:typescript": "./bin/cli.js start --config cypress/projects/typescript/playroom.config.js",
|
|
121
|
+
"build:typescript": "./bin/cli.js build --config cypress/projects/typescript/playroom.config.js",
|
|
122
|
+
"serve:typescript": "PORT=9002 serve --no-request-logging cypress/projects/typescript/dist",
|
|
123
|
+
"start:all": "concurrently 'npm:start:*(!all)'",
|
|
124
|
+
"build:all": "concurrently 'npm:build:*(!all)'",
|
|
125
|
+
"serve:all": "concurrently 'npm:serve:*(!all)'",
|
|
123
126
|
"build-and-serve:all": "pnpm build:all && pnpm serve:all",
|
|
124
|
-
"lint": "
|
|
127
|
+
"lint": "concurrently 'npm:lint:*'",
|
|
128
|
+
"lint:eslint": "eslint --cache .",
|
|
129
|
+
"lint:prettier": "prettier --list-different '**/*.{js,md,ts,tsx}'",
|
|
130
|
+
"lint:tsc": "tsc --noEmit",
|
|
131
|
+
"lint:cypress": "tsc --project cypress/tsconfig.json",
|
|
125
132
|
"format": "prettier --write '**/*.{js,md,ts,tsx}'",
|
|
126
133
|
"version": "changeset version",
|
|
127
134
|
"release": "changeset publish",
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useRef, useContext, useEffect, useCallback } from 'react';
|
|
2
|
+
// @ts-expect-error no types
|
|
2
3
|
import { useDebouncedCallback } from 'use-debounce';
|
|
3
|
-
import { Editor } from 'codemirror';
|
|
4
|
+
import type { Editor } from 'codemirror';
|
|
4
5
|
import 'codemirror/lib/codemirror.css';
|
|
5
6
|
import 'codemirror/theme/neo.css';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
StoreContext,
|
|
10
|
+
type CursorPosition,
|
|
11
|
+
} from '../../StoreContext/StoreContext';
|
|
8
12
|
import { formatCode as format, isMac } from '../../utils/formatting';
|
|
9
13
|
import {
|
|
10
14
|
closeFragmentTag,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import CodeMirror, { Editor, Pos } from 'codemirror';
|
|
1
|
+
import CodeMirror, { type Editor, Pos } from 'codemirror';
|
|
2
2
|
|
|
3
3
|
import 'codemirror/addon/search/searchcursor';
|
|
4
4
|
|
|
5
|
-
import { Direction, Selection } from './types';
|
|
5
|
+
import type { Direction, Selection } from './types';
|
|
6
6
|
|
|
7
7
|
function wordAt(cm: Editor, pos: CodeMirror.Position) {
|
|
8
8
|
let start = pos.ch;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import CodeMirror from 'codemirror';
|
|
2
|
-
import {
|
|
3
|
-
import { Direction, Selection } from './types';
|
|
1
|
+
import CodeMirror, { type Editor, Pos } from 'codemirror';
|
|
2
|
+
import type { Direction, Selection } from './types';
|
|
4
3
|
type RangeMethod = Extract<keyof CodeMirror.Range, 'from' | 'to'>;
|
|
5
4
|
|
|
6
5
|
const directionToMethod: Record<Direction, RangeMethod> = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import CodeMirror
|
|
2
|
-
import {
|
|
1
|
+
import type CodeMirror from 'codemirror';
|
|
2
|
+
import { type Editor, Pos } from 'codemirror';
|
|
3
|
+
import type { Selection } from './types';
|
|
3
4
|
|
|
4
5
|
interface TagRange {
|
|
5
6
|
from: CodeMirror.Position;
|
package/src/Playroom/Frame.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
import flatMap from 'lodash/flatMap';
|
|
3
3
|
import Iframe from './Iframe';
|
|
4
4
|
import { compileJsx } from '../../utils/compileJsx';
|
|
5
|
-
import { PlayroomProps } from '../Playroom';
|
|
5
|
+
import type { PlayroomProps } from '../Playroom';
|
|
6
6
|
import { Strong } from '../Strong/Strong';
|
|
7
7
|
import { Text } from '../Text/Text';
|
|
8
8
|
import playroomConfig from '../../config';
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useContext, type ComponentType, Fragment } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
+
// @ts-expect-error no types
|
|
3
4
|
import { useDebouncedCallback } from 'use-debounce';
|
|
4
5
|
import { Resizable } from 're-resizable';
|
|
5
6
|
import Frames from './Frames/Frames';
|
|
6
7
|
import { WindowPortal } from './WindowPortal';
|
|
7
|
-
import { Snippets } from '../../utils';
|
|
8
|
+
import type { Snippets } from '../../utils';
|
|
8
9
|
import componentsToHints from '../utils/componentsToHints';
|
|
9
10
|
import Toolbar, { toolbarItemCount } from './Toolbar/Toolbar';
|
|
10
11
|
import ChevronIcon from './icons/ChevronIcon';
|
|
11
12
|
import { StatusMessage } from './StatusMessage/StatusMessage';
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
StoreContext,
|
|
15
|
+
type EditorPosition,
|
|
16
|
+
} from '../StoreContext/StoreContext';
|
|
13
17
|
|
|
14
18
|
const MIN_HEIGHT = toolbarItemSize * toolbarItemCount;
|
|
15
19
|
const MIN_WIDTH = toolbarOpenSize + toolbarItemSize + 80;
|
package/src/Playroom/Preview.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useContext, ReactChild } from 'react';
|
|
1
|
+
import React, { useContext, type ReactChild } from 'react';
|
|
2
2
|
import { Heading } from '../Heading/Heading';
|
|
3
3
|
import { ToolbarPanel } from '../ToolbarPanel/ToolbarPanel';
|
|
4
4
|
import {
|
|
5
|
-
ColorScheme,
|
|
6
|
-
EditorPosition,
|
|
5
|
+
type ColorScheme,
|
|
6
|
+
type EditorPosition,
|
|
7
7
|
StoreContext,
|
|
8
8
|
} from '../../StoreContext/StoreContext';
|
|
9
9
|
import { Stack } from '../Stack/Stack';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import fuzzy from 'fuzzy';
|
|
4
|
+
// @ts-expect-error no types
|
|
4
5
|
import { useDebouncedCallback } from 'use-debounce';
|
|
5
|
-
import { PlayroomProps } from '../Playroom';
|
|
6
|
-
import { Snippet } from '../../../utils';
|
|
6
|
+
import type { PlayroomProps } from '../Playroom';
|
|
7
|
+
import type { Snippet } from '../../../utils';
|
|
7
8
|
import SearchField from './SearchField/SearchField';
|
|
8
9
|
import { Strong } from '../Strong/Strong';
|
|
9
10
|
import { Text } from '../Text/Text';
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
useContext,
|
|
3
|
-
useState,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useCallback,
|
|
7
|
-
} from 'react';
|
|
1
|
+
import { useContext, useState, useEffect, useRef, useCallback } from 'react';
|
|
8
2
|
import classnames from 'classnames';
|
|
9
3
|
import { StoreContext } from '../../StoreContext/StoreContext';
|
|
10
4
|
import { Text } from '../Text/Text';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useContext, useState, useCallback } from 'react';
|
|
2
2
|
import { useTimeoutFn } from 'react-use';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import { PlayroomProps } from '../Playroom';
|
|
4
|
+
import type { PlayroomProps } from '../Playroom';
|
|
5
5
|
import { StoreContext } from '../../StoreContext/StoreContext';
|
|
6
6
|
import FramesPanel from '../FramesPanel/FramesPanel';
|
|
7
7
|
import PreviewPanel from '../PreviewPanel/PreviewPanel';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
2
|
useEffect,
|
|
3
3
|
createContext,
|
|
4
4
|
useReducer,
|
|
5
|
-
ReactNode,
|
|
6
|
-
Dispatch,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
type Dispatch,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import copy from 'copy-to-clipboard';
|
|
9
9
|
import localforage from 'localforage';
|
|
10
10
|
import lzString from 'lz-string';
|
|
11
11
|
import dedent from 'dedent';
|
|
12
|
+
// @ts-expect-error no types
|
|
12
13
|
import { useDebouncedCallback } from 'use-debounce';
|
|
13
14
|
|
|
14
|
-
import { Snippet, compressParams } from '../../utils';
|
|
15
|
+
import { type Snippet, compressParams } from '../../utils';
|
|
15
16
|
import { formatForInsertion, formatAndInsert } from '../utils/formatting';
|
|
16
17
|
import { getParamsFromQuery, updateUrlCode } from '../utils/params';
|
|
17
|
-
import { PlayroomProps } from '../Playroom/Playroom';
|
|
18
|
+
import type { PlayroomProps } from '../Playroom/Playroom';
|
|
18
19
|
import { isValidLocation } from '../utils/cursor';
|
|
19
20
|
import playroomConfig from '../config';
|
|
20
21
|
|
package/src/frame.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ interface PlayroomConfig {
|
|
|
13
13
|
baseUrl?: string;
|
|
14
14
|
paramType: 'hash' | 'search';
|
|
15
15
|
iframeSandbox?: string;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
16
17
|
reactDocgenTypescriptConfig?: import('react-docgen-typescript').ParserOptions;
|
|
17
18
|
}
|
|
18
19
|
|
package/src/index.js
CHANGED
package/src/preview.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import omit from 'lodash/omit';
|
|
2
2
|
// @ts-expect-error
|
|
3
3
|
import parsePropTypes from 'parse-prop-types';
|
|
4
|
-
import { PlayroomProps } from '../Playroom/Playroom';
|
|
4
|
+
import type { PlayroomProps } from '../Playroom/Playroom';
|
|
5
5
|
|
|
6
6
|
const staticTypes = __PLAYROOM_GLOBAL__STATIC_TYPES__;
|
|
7
7
|
|
package/src/utils/cursor.ts
CHANGED
package/src/utils/formatting.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import prettier from 'prettier/standalone';
|
|
2
2
|
import babel from 'prettier/parser-babel';
|
|
3
|
-
import { CursorPosition } from '../StoreContext/StoreContext';
|
|
3
|
+
import type { CursorPosition } from '../StoreContext/StoreContext';
|
|
4
4
|
import { insertAtCursor } from './cursor';
|
|
5
5
|
|
|
6
6
|
export interface CodeWithCursor {
|
package/src/utils/params.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"noEmit": true,
|
|
4
4
|
"skipLibCheck": true,
|
|
5
|
-
"
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"module": "es2022",
|
|
6
7
|
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"isolatedModules": true,
|
|
7
10
|
"resolveJsonModule": true,
|
|
8
11
|
"noUnusedLocals": true,
|
|
9
12
|
"strict": true,
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"lib": ["dom", "es2022"],
|
|
16
|
+
"target": "es2022"
|
|
13
17
|
},
|
|
14
|
-
"include": ["
|
|
18
|
+
"include": ["src", "@types"],
|
|
19
|
+
"exclude": ["cypress", "node_modules"]
|
|
15
20
|
}
|
package/cypress/.eslintrc
DELETED
|
File without changes
|