@forge/react 1.1.0-next.0 → 1.1.0-next.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/out/__test__/styles.test.d.ts +2 -0
  3. package/out/__test__/styles.test.d.ts.map +1 -0
  4. package/out/__test__/styles.test.js +88 -0
  5. package/out/components.d.ts +44 -0
  6. package/out/components.d.ts.map +1 -0
  7. package/out/components.js +45 -0
  8. package/{src/index.ts → out/index.d.ts} +2 -1
  9. package/out/index.d.ts.map +1 -0
  10. package/out/index.js +7 -0
  11. package/out/reconciler.d.ts +5 -0
  12. package/out/reconciler.d.ts.map +1 -0
  13. package/out/reconciler.js +143 -0
  14. package/out/styles/index.d.ts +28 -0
  15. package/out/styles/index.d.ts.map +1 -0
  16. package/out/styles/index.js +152 -0
  17. package/out/types/components.d.ts +369 -0
  18. package/out/types/components.d.ts.map +1 -0
  19. package/out/types/components.js +2 -0
  20. package/out/types/effect.d.ts +57 -0
  21. package/out/types/effect.d.ts.map +1 -0
  22. package/out/types/effect.js +19 -0
  23. package/out/types/extension.d.ts +10 -0
  24. package/out/types/extension.d.ts.map +1 -0
  25. package/out/types/extension.js +2 -0
  26. package/out/types/forge.d.ts +146 -0
  27. package/out/types/forge.d.ts.map +1 -0
  28. package/out/types/forge.js +21 -0
  29. package/out/types/icons.d.ts +2 -0
  30. package/out/types/icons.d.ts.map +1 -0
  31. package/out/types/icons.js +2 -0
  32. package/out/types/index.d.ts +11 -0
  33. package/out/types/index.d.ts.map +1 -0
  34. package/out/types/index.js +27 -0
  35. package/out/types/legacy-effect.d.ts +40 -0
  36. package/out/types/legacy-effect.d.ts.map +1 -0
  37. package/out/types/legacy-effect.js +21 -0
  38. package/out/types/styles.d.ts +134 -0
  39. package/out/types/styles.d.ts.map +1 -0
  40. package/out/types/styles.js +2 -0
  41. package/package.json +1 -1
  42. package/tsconfig.tsbuildinfo +1078 -0
  43. package/build/bundle-types.sh +0 -21
  44. package/src/__test__/styles.test.tsx +0 -112
  45. package/src/globals.d.ts +0 -12
  46. package/src/reconciler.ts +0 -219
  47. package/src/styles/index.ts +0 -174
  48. package/tsconfig.json +0 -9
@@ -1,21 +0,0 @@
1
- #! /bin/bash
2
- set -exu
3
- VERSION=27.1.0
4
-
5
- clean () { rm -rf ./tmp; }
6
-
7
- cd $(dirname $0)
8
- rm -rf ./tmp
9
- rm -rf ../src/types
10
-
11
- mkdir ./tmp
12
- trap clean EXIT
13
-
14
- mkdir ../src/types
15
-
16
- # Pulls @atlassian/forge-ui-types and copies public types
17
- (cd ./tmp
18
- npm pack "@atlassian/forge-ui-types@$VERSION"
19
- tar -xvf *.tgz
20
- cp -R "./package/src/public/." "../../src/types/."
21
- )
@@ -1,112 +0,0 @@
1
- import {
2
- active,
3
- focus,
4
- gradientStep,
5
- hover,
6
- linearGradient,
7
- radialGradient,
8
- rgba,
9
- rotate,
10
- scale,
11
- skew,
12
- StyleSheet,
13
- translate,
14
- url
15
- } from '../styles';
16
-
17
- describe('StyleSheet', () => {
18
- it('should create valid basic styles object', () => {
19
- expect(
20
- StyleSheet.create({
21
- container: {
22
- backgroundColor: '#fff',
23
- backgroundImage: [
24
- url('/image.png'),
25
- linearGradient('90deg', gradientStep('10%', 'red'), gradientStep('30%', 'blue'))
26
- ],
27
- backgroundSize: ['cover', ['50%', '50%']]
28
- }
29
- })
30
- ).toEqual({
31
- container: {
32
- backgroundColor: '#fff',
33
- backgroundImage: [
34
- { method: 'url', value: { path: '/image.png' } },
35
- {
36
- method: 'gradient',
37
- value: {
38
- colors: [
39
- { percent: '10%', value: 'red' },
40
- { percent: '30%', value: 'blue' }
41
- ],
42
- degrees: '90deg',
43
- type: 'linear'
44
- }
45
- }
46
- ],
47
- backgroundSize: ['cover', ['50%', '50%']]
48
- }
49
- });
50
- });
51
-
52
- it('should create valid composed styles object', () => {
53
- expect(
54
- StyleSheet.create({
55
- container: (compose) =>
56
- compose(
57
- {
58
- backgroundColor: 'red',
59
- backgroundImage: url('https://example.test/image.png'),
60
- backgroundPosition: ['50px', '50px', '50px', '50px'],
61
- transform: [
62
- translate('10px', '10px', '10px'),
63
- scale('2', '2', '2'),
64
- rotate('45deg', '45deg', '45deg'),
65
- skew('45deg', '45deg')
66
- ]
67
- },
68
- active({
69
- backgroundColor: rgba(0, 0, 255, 1),
70
- backgroundImage: radialGradient(gradientStep('10%', 'red'), gradientStep('30%', 'blue')),
71
- backgroundPosition: ['50px', '50px']
72
- }),
73
- hover({
74
- backgroundPosition: 'center',
75
- backgroundRepeat: 'no-repeat'
76
- }),
77
- focus({
78
- backgroundRepeat: ['repeat', 'repeat']
79
- })
80
- )
81
- })
82
- ).toEqual({
83
- container: {
84
- __active: {
85
- backgroundColor: { method: 'rgba', value: { a: 1, b: 255, g: 0, r: 0 } },
86
- backgroundImage: {
87
- method: 'gradient',
88
- value: {
89
- colors: [
90
- { percent: '10%', value: 'red' },
91
- { percent: '30%', value: 'blue' }
92
- ],
93
- type: 'radial'
94
- }
95
- },
96
- backgroundPosition: ['50px', '50px']
97
- },
98
- __focus: { backgroundRepeat: ['repeat', 'repeat'] },
99
- __hover: { backgroundPosition: 'center', backgroundRepeat: 'no-repeat' },
100
- backgroundColor: 'red',
101
- backgroundImage: { method: 'url', value: { path: 'https://example.test/image.png' } },
102
- backgroundPosition: ['50px', '50px', '50px', '50px'],
103
- transform: [
104
- { method: 'translate', value: { x: '10px', y: '10px', z: '10px' } },
105
- { method: 'scale', value: { x: '2', y: '2', z: '2' } },
106
- { method: 'rotate', value: { x: '45deg', y: '45deg', z: '45deg' } },
107
- { method: 'skew', value: { x: '45deg', y: '45deg' } }
108
- ]
109
- }
110
- });
111
- });
112
- });
package/src/globals.d.ts DELETED
@@ -1,12 +0,0 @@
1
- interface GlobalBridge {
2
- callBridge(action: 'reconcile', payload: any): Promise<any>;
3
- __SEMVER: string;
4
- }
5
-
6
- declare module '@forge/react' {
7
- global {
8
- interface Window {
9
- __bridge: GlobalBridge;
10
- }
11
- }
12
- }
package/src/reconciler.ts DELETED
@@ -1,219 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-empty-function */
2
- import Reconciler, { HostConfig } from 'react-reconciler';
3
- import { DefaultEventPriority } from 'react-reconciler/constants';
4
- import { v4 as uuid } from 'uuid';
5
-
6
- type ElementType = string;
7
- type ElementProps = { [key: string]: any };
8
-
9
- interface ForgeDoc {
10
- type: string;
11
- props: { [key: string]: any };
12
- children: ForgeDoc[];
13
- key: string;
14
- }
15
-
16
- // @ts-ignore
17
- const callBridge = self.__bridge.callBridge;
18
-
19
- const createElement = (type: ElementType, props: ElementProps = {}): ForgeDoc => {
20
- const { children, ...restProps } = props;
21
- return {
22
- type,
23
- children: [],
24
- props: restProps,
25
- key: uuid()
26
- };
27
- };
28
-
29
- const appendChild = (parent: ForgeDoc, child: ForgeDoc) => {
30
- if (parent.children.includes(child)) {
31
- const removeIndex = parent.children.indexOf(child);
32
- parent.children.splice(removeIndex, 1);
33
- }
34
- parent.children.push(child);
35
- };
36
-
37
- const insertBefore = (parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc) => {
38
- const insertIndex = parent.children.indexOf(beforeChild);
39
- if (parent.children.includes(child)) {
40
- const removeIndex = parent.children.indexOf(child);
41
- parent.children.splice(removeIndex, 1);
42
- }
43
- parent.children.splice(insertIndex, 0, child);
44
- };
45
-
46
- const hostConfig: HostConfig<
47
- string, // Type
48
- Record<string, any>, // Props
49
- ForgeDoc, // Container
50
- ForgeDoc, // Instance
51
- ForgeDoc, // TextInstance
52
- ForgeDoc, // SuspenseInstance
53
- ForgeDoc, // HydratableInstance
54
- ForgeDoc, // PublicInstance
55
- any, // HostContext
56
- any, // UpdatePayload,
57
- any, // _ChildSet
58
- any, // TimeoutHandle
59
- any // NoTimeout
60
- > = {
61
- supportsMutation: true,
62
- supportsPersistence: false,
63
- noTimeout: -1,
64
- isPrimaryRenderer: false,
65
- supportsHydration: false,
66
-
67
- resetAfterCommit(forgeDoc: ForgeDoc): void {
68
- callBridge('reconcile', { forgeDoc });
69
- },
70
-
71
- createInstance(type: ElementType, props: ElementProps) {
72
- const element = createElement(type, props);
73
- return element;
74
- },
75
-
76
- createTextInstance(text: string): ForgeDoc {
77
- return {
78
- type: 'String',
79
- children: [],
80
- props: {
81
- text
82
- },
83
- key: uuid()
84
- };
85
- },
86
-
87
- appendInitialChild(parent: ForgeDoc, child: ForgeDoc): void {
88
- appendChild(parent, child);
89
- },
90
-
91
- appendChild(parent: ForgeDoc, child: ForgeDoc): void {
92
- appendChild(parent, child);
93
- },
94
-
95
- appendChildToContainer(container: ForgeDoc, child: ForgeDoc): void {
96
- appendChild(container, child);
97
- },
98
-
99
- finalizeInitialChildren(): boolean {
100
- return false;
101
- },
102
-
103
- prepareUpdate(instance: ForgeDoc, type: ElementType, oldProps: ElementProps, newProps: ElementProps): ElementProps {
104
- instance.props = newProps;
105
- return newProps;
106
- },
107
-
108
- shouldSetTextContent(): boolean {
109
- return false;
110
- },
111
-
112
- getRootHostContext() {
113
- return {};
114
- },
115
-
116
- getChildHostContext(parentContext, fiberType): null {
117
- return null;
118
- },
119
-
120
- getPublicInstance(instance: ForgeDoc): ForgeDoc {
121
- return instance;
122
- },
123
-
124
- prepareForCommit(): null {
125
- return null;
126
- },
127
-
128
- preparePortalMount(): void {},
129
-
130
- scheduleTimeout(fn: () => void, delay: number): any {
131
- return setTimeout(fn, delay);
132
- },
133
-
134
- cancelTimeout(id): void {
135
- clearTimeout(id);
136
- },
137
-
138
- insertBefore(parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc): void {
139
- insertBefore(parent, child, beforeChild);
140
- },
141
-
142
- insertInContainerBefore(container: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc): void {
143
- insertBefore(container, child, beforeChild);
144
- },
145
-
146
- removeChild(parent: ForgeDoc, child: ForgeDoc): void {
147
- const removeIndex = parent.children.indexOf(child);
148
- parent.children.splice(removeIndex, 1);
149
- },
150
-
151
- removeChildFromContainer(container: ForgeDoc, child: ForgeDoc): void {
152
- const removeIndex = container.children.indexOf(child);
153
- container.children.splice(removeIndex, 1);
154
- },
155
-
156
- resetTextContent(): void {},
157
-
158
- commitTextUpdate(textInstance: ForgeDoc, oldText: string, newText: string): void {
159
- textInstance.props.text = newText;
160
- },
161
-
162
- commitMount(): void {},
163
-
164
- commitUpdate(): void {},
165
-
166
- hideInstance(): void {},
167
-
168
- hideTextInstance(): void {},
169
-
170
- unhideInstance(): void {},
171
-
172
- unhideTextInstance(): void {},
173
-
174
- clearContainer(): void {},
175
-
176
- detachDeletedInstance(instance: ForgeDoc): void {},
177
-
178
- getCurrentEventPriority() {
179
- return DefaultEventPriority;
180
- },
181
-
182
- getInstanceFromNode(): null {
183
- return null;
184
- },
185
-
186
- beforeActiveInstanceBlur(): void {},
187
-
188
- afterActiveInstanceBlur(): void {},
189
-
190
- prepareScopeUpdate(): void {},
191
-
192
- getInstanceFromScope(): null {
193
- return null;
194
- }
195
- };
196
-
197
- const reconciler = Reconciler(hostConfig);
198
-
199
- export const ForgeReconciler = {
200
- render: (element: any): void => {
201
- const rootElement = createElement('Root');
202
- const container = reconciler.createContainer(
203
- rootElement,
204
- 0,
205
- null,
206
- false,
207
- null,
208
- 'root',
209
- (err: any) => {
210
- // eslint-disable-next-line no-console
211
- console.log(err);
212
- },
213
- null
214
- );
215
- reconciler.updateContainer(element, container, null, null);
216
- }
217
- };
218
-
219
- export default ForgeReconciler;
@@ -1,174 +0,0 @@
1
- import {
2
- AllowedPrimitives,
3
- Definitions,
4
- GradientValue,
5
- RGBAColorValue,
6
- ShadowValue,
7
- TransformValue,
8
- ColorType,
9
- URLValue
10
- } from '../types';
11
-
12
- export interface PreDefinitions {
13
- [key: string]: AllowedPrimitives | ComposeProvider;
14
- }
15
-
16
- export type Compose = (...primitiveObjects: AllowedPrimitives[]) => AllowedPrimitives;
17
- export type ComposeProvider = (compose: Compose) => AllowedPrimitives;
18
-
19
- export const StyleSheet = {
20
- create(definitions: PreDefinitions): Definitions {
21
- const stylesheet: Definitions = {};
22
-
23
- for (const key in definitions) {
24
- const definition = definitions[key];
25
- if (typeof definition === 'function') {
26
- const compose = (...primitivesDefinitions: AllowedPrimitives[]): AllowedPrimitives => {
27
- return primitivesDefinitions.reduce((acc, primitives) => {
28
- return { ...acc, ...primitives };
29
- }, {});
30
- };
31
- stylesheet[key] = definition(compose);
32
- } else {
33
- stylesheet[key] = definition;
34
- }
35
- }
36
- return stylesheet;
37
- }
38
- };
39
-
40
- export const rgba = (r: number, g: number, b: number, a: number): RGBAColorValue => {
41
- return {
42
- method: 'rgba',
43
- value: {
44
- r,
45
- g,
46
- b,
47
- a
48
- }
49
- };
50
- };
51
-
52
- export const rgb = (r: number, g: number, b: number): RGBAColorValue => {
53
- return {
54
- method: 'rgb',
55
- value: {
56
- r,
57
- g,
58
- b
59
- }
60
- };
61
- };
62
-
63
- export function shadow(offsets: string, color: string | RGBAColorValue): ShadowValue {
64
- return {
65
- method: 'shadow',
66
- value: {
67
- offsets,
68
- color
69
- }
70
- };
71
- }
72
-
73
- export interface GradientStep {
74
- percent: string;
75
- value: ColorType;
76
- }
77
-
78
- export function gradientStep(percent: string, value: ColorType): GradientStep {
79
- return {
80
- percent,
81
- value
82
- };
83
- }
84
-
85
- export function linearGradient(degrees: string, ...steps: GradientStep[]): GradientValue {
86
- return {
87
- method: 'gradient',
88
- value: {
89
- type: 'linear',
90
- colors: steps,
91
- degrees
92
- }
93
- };
94
- }
95
-
96
- export function radialGradient(...steps: GradientStep[]): GradientValue {
97
- return {
98
- method: 'gradient',
99
- value: {
100
- type: 'radial',
101
- colors: steps
102
- }
103
- };
104
- }
105
-
106
- export function translate(x?: string, y?: string, z?: string): TransformValue {
107
- return {
108
- method: 'translate',
109
- value: {
110
- x,
111
- y,
112
- z
113
- }
114
- };
115
- }
116
-
117
- export function scale(x?: string, y?: string, z?: string): TransformValue {
118
- return {
119
- method: 'scale',
120
- value: {
121
- x,
122
- y,
123
- z
124
- }
125
- };
126
- }
127
-
128
- export function rotate(x?: string, y?: string, z?: string): TransformValue {
129
- return {
130
- method: 'rotate',
131
- value: {
132
- x,
133
- y,
134
- z
135
- }
136
- };
137
- }
138
-
139
- export function skew(x?: string, y?: string): TransformValue {
140
- return {
141
- method: 'skew',
142
- value: {
143
- x,
144
- y
145
- }
146
- };
147
- }
148
-
149
- export function url(path: string): URLValue {
150
- return {
151
- method: 'url',
152
- value: {
153
- path
154
- }
155
- };
156
- }
157
-
158
- export function focus(primitives: AllowedPrimitives): AllowedPrimitives {
159
- return {
160
- __focus: primitives
161
- };
162
- }
163
-
164
- export function hover(primitives: AllowedPrimitives): AllowedPrimitives {
165
- return {
166
- __hover: primitives
167
- };
168
- }
169
-
170
- export function active(primitives: AllowedPrimitives): AllowedPrimitives {
171
- return {
172
- __active: primitives
173
- };
174
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "outDir": "./out",
5
- "rootDir": "src",
6
- "composite": true
7
- },
8
- "references": []
9
- }