Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5f69886
added Group Observer
bennobuilder Jun 20, 2021
6fe58dc
Added group observer
bennobuilder Jun 20, 2021
23da594
made vue integration work with split observers
bennobuilder Jun 20, 2021
6ccfca2
made extracting value or output optional
bennobuilder Jun 20, 2021
7ce64a5
Outsourced extract relevant observers
bennobuilder Jun 20, 2021
9172752
implemented extract relevant observers into React integration
bennobuilder Jun 21, 2021
313c176
fixed vue example
bennobuilder Jun 21, 2021
7ad0b0b
added useOutput and useValue
bennobuilder Jun 21, 2021
53ee465
added rough boxes example (not working yet)
bennobuilder Jun 21, 2021
3f41fec
added basic useSelector
bennobuilder Jun 22, 2021
227901b
fixed useSelector type
bennobuilder Jun 22, 2021
1490be3
made proxy tree in react package optional
bennobuilder Jun 22, 2021
886a203
removed items from Group
bennobuilder Jun 23, 2021
65cbdc3
fixed some tests
bennobuilder Jun 23, 2021
9049260
expanded group observer tests
bennobuilder Jun 23, 2021
66890e2
fixed some more tests
bennobuilder Jun 24, 2021
652cdb6
fixed state observer tests
bennobuilder Jun 24, 2021
27f9266
added extractObservers function tests
bennobuilder Jun 24, 2021
0681544
added extractRelevantObservers tests
bennobuilder Jun 24, 2021
06225ab
fixed typos
bennobuilder Jun 25, 2021
76929be
added optionalRequire util function
bennobuilder Jun 25, 2021
af35f56
fixed tests
bennobuilder Jun 25, 2021
bff4fc2
fixed typos
bennobuilder Jun 26, 2021
a955913
fixed multieditor error
bennobuilder Jun 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/react/develop/functional-component-ts/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import './App.css';
import { useAgile, useWatcher, useProxy } from '@agile-ts/react';
import { useAgile, useWatcher, useProxy, useSelector } from '@agile-ts/react';
import { useEvent } from '@agile-ts/event';
import {
COUNTUP,
Expand Down Expand Up @@ -43,6 +43,10 @@ const App = (props: any) => {
]);
const [myGroup] = useAgile([MY_COLLECTION.getGroupWithReference('myGroup')]);

const selectedObjectItem = useSelector(STATE_OBJECT, (value) => {
return value.age;
});

const [stateObject, item2, collection2] = useProxy(
[STATE_OBJECT, MY_COLLECTION.getItem('id2'), MY_COLLECTION],
{ key: 'useProxy' }
Expand Down Expand Up @@ -106,7 +110,8 @@ const App = (props: any) => {
<div className={'Container'}>
<h3 className={'Title'}>My State Object</h3>
<p>
Deep Name: {stateObject.friends.hans.name} {stateObject.location}
Deep Name: {stateObject?.friends?.hans?.name}{' '}
{stateObject?.location}
</p>
<button
onClick={() => {
Expand All @@ -132,7 +137,7 @@ const App = (props: any) => {
<div className={'Container'}>
<h3 className={'Title'}>My Collection</h3>
<div>
{myGroup.map((item) => (
{myGroup?.map((item) => (
<p key={item.key}>{item.name}</p>
))}
</div>
Expand Down
1 change: 1 addition & 0 deletions examples/react/release/boxes/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
24 changes: 24 additions & 0 deletions examples/react/release/boxes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.idea

npm-debug.log*
yarn-debug.log*
yarn-error.log*
57 changes: 57 additions & 0 deletions examples/react/release/boxes/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "boxes",
"version": "0.1.0",
"private": true,
"dependencies": {
"@agile-ts/api": "file:.yalc/@agile-ts/api",
"@agile-ts/core": "file:.yalc/@agile-ts/core",
"@agile-ts/event": "file:.yalc/@agile-ts/event",
"@agile-ts/multieditor": "file:.yalc/@agile-ts/multieditor",
"@agile-ts/proxytree": "file:.yalc/@agile-ts/proxytree",
"@agile-ts/react": "file:.yalc/@agile-ts/react",
"@chakra-ui/react": "^1.6.3",
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"framer-motion": "^4.1.17",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-draggable": "^4.4.3",
"react-feather": "^2.0.9",
"react-resizable": "^3.0.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-resizable": "^1.7.2",
"@types/react-router-dom": "^5.1.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event @agile-ts/proxytree & yarn install"
},
"eslintConfig": {
"extends": [
"react-app"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/react/release/boxes/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/react/release/boxes/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/react/release/boxes/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react/release/boxes/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/react/release/boxes/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions examples/react/release/boxes/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
18 changes: 18 additions & 0 deletions examples/react/release/boxes/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

import Canvas from './screens/Canvas';

function App() {
return (
<Router>
<Switch>
<Route>
<Canvas />
</Route>
</Switch>
</Router>
);
}

export default App;
26 changes: 26 additions & 0 deletions examples/react/release/boxes/src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import queryString, {ParsedUrlQueryInput} from 'querystring'

type RequestOptions = {
queryParams?: ParsedUrlQueryInput
method?: 'GET' | 'POST'
body?: object | string
}

export const apiUrl = (lambda: string, queryParams?: ParsedUrlQueryInput) => {
let url = `https://f10adraov8.execute-api.us-east-1.amazonaws.com/dev/${lambda}`
if (queryParams) url += '?' + queryString.stringify(queryParams)

return url
}

export const callApi = (lambda: string, options?: RequestOptions) => {
const {queryParams, body, method} = options || {}
const url = apiUrl(lambda, queryParams)

let bodyString = body
if (typeof bodyString === 'object') {
bodyString = JSON.stringify(body)
}

return fetch(url, {body: bodyString, method}).then((res) => res.json())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useEffect, useState } from 'react';
import { Box, Text, VStack } from '@chakra-ui/layout';
import { Skeleton } from '@chakra-ui/skeleton';
import { callApi } from '../../../api';
import { SELECTED_ELEMENT } from '../../../core/entities/ui/ui.controller';
import { useProxy } from '@agile-ts/react';

export const ImageInfo = () => {
const element = useProxy(SELECTED_ELEMENT);
const [imageInfo, setImageInfo] = useState<{
author: string;
url: string;
} | null>(null);

useEffect(() => {
if (element?.image) {
callApi('image-details', {
queryParams: { seed: element.image.id },
}).then((value) => {
setImageInfo(value);
});
}
}, [element?.image?.id]);

return (
<VStack spacing={2} alignItems="flex-start" width="100%">
<Info label="Author" value={imageInfo?.author} />
<Info label="Image URL" value={imageInfo?.url} />
</VStack>
);
};

export const ImageInfoFallback = () => {
return (
<VStack spacing={2} alignItems="flex-start" width="100%">
<Info label="Author" />
<Info label="Image URL" />
</VStack>
);
};

export const Info = ({ label, value }: { label: string; value?: string }) => {
return (
<Box width="175px">
<Text fontSize="14px" fontWeight="500" mb="2px">
{label}
</Text>
{value === undefined ? (
<Skeleton width="100%" height="21px" />
) : (
<Text fontSize="14px">{value}</Text>
)}
</Box>
);
};
Loading