mathbox-react 0.0.11-rc → 0.0.13

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 (45) hide show
  1. package/build/cjs/components/components.d.ts +2 -2
  2. package/build/cjs/components/types.d.ts +2 -2
  3. package/build/cjs/components/util.d.ts +1 -1
  4. package/build/cjs/index.js +1 -1
  5. package/build/cjs/index.js.map +1 -1
  6. package/build/esm/components/components.d.ts +2 -2
  7. package/build/esm/components/types.d.ts +2 -2
  8. package/build/esm/components/util.d.ts +1 -1
  9. package/build/esm/index.js +1 -1
  10. package/build/esm/index.js.map +1 -1
  11. package/build/index.d.ts +4 -4
  12. package/package.json +12 -17
  13. package/.eslintrc.js +0 -72
  14. package/.github/renovate.json +0 -13
  15. package/.github/workflows/lint.yaml +0 -20
  16. package/.prettierrc +0 -1
  17. package/.storybook/main.js +0 -9
  18. package/.storybook/preview.js +0 -11
  19. package/LICENSE +0 -29
  20. package/README.md +0 -6
  21. package/babel.config.js +0 -3
  22. package/build/cjs/components/components.spec.d.ts +0 -1
  23. package/build/cjs/stories/utils.d.ts +0 -5
  24. package/build/esm/components/components.spec.d.ts +0 -1
  25. package/build/esm/stories/utils.d.ts +0 -5
  26. package/jest.config.js +0 -12
  27. package/rollup.config.js +0 -38
  28. package/src/components/ContainedMathbox.tsx +0 -38
  29. package/src/components/Mathbox.tsx +0 -63
  30. package/src/components/MathboxNodeContext.ts +0 -6
  31. package/src/components/components.spec.tsx +0 -311
  32. package/src/components/components.tsx +0 -443
  33. package/src/components/index.ts +0 -3
  34. package/src/components/types.ts +0 -9
  35. package/src/components/util.ts +0 -106
  36. package/src/index.ts +0 -1
  37. package/src/stories/Cartesian.stories.tsx +0 -36
  38. package/src/stories/Grid.stories.tsx +0 -38
  39. package/src/stories/Mathbox.stories.tsx +0 -16
  40. package/src/stories/Point.stories.tsx +0 -75
  41. package/src/stories/utils.tsx +0 -33
  42. package/src/testSetup.ts +0 -3
  43. package/src/testUtils.ts +0 -46
  44. package/tsconfig.base.json +0 -17
  45. package/tsconfig.json +0 -5
@@ -1,75 +0,0 @@
1
- import React, { useState } from "react"
2
- import { Story, Meta } from "@storybook/react"
3
- import { MathboxSelection } from "mathbox"
4
- import { CustomMathbox as Mathbox } from "./utils"
5
- import { Cartesian, Grid, Point, Array as MBArray } from "../components"
6
-
7
- export default {
8
- title: "Point",
9
- component: Point,
10
- argTypes: {
11
- color: {
12
- type: "string",
13
- default: "rgb(128, 128, 128)",
14
- },
15
- opacity: {
16
- type: "number",
17
- default: 1,
18
- },
19
- points: {
20
- type: "array",
21
- default: [[1, 1, 1]],
22
- },
23
- size: {
24
- type: "number",
25
- default: 4,
26
- },
27
- },
28
- } as Meta<typeof Grid>
29
-
30
- const Template: Story<React.ComponentProps<typeof Point>> = (args) => {
31
- const { points, ...otherArgs } = args
32
- const [data, setData] = useState<MathboxSelection<"array"> | null>(null)
33
- return (
34
- <Mathbox containerStyle={{ height: 450 }}>
35
- <Cartesian
36
- range={[
37
- [-5, 5],
38
- [-5, 5],
39
- [-5, 5],
40
- ]}
41
- >
42
- <Grid axes="xy" />
43
- <Grid axes="xz" />
44
- <MBArray
45
- ref={setData}
46
- items={1}
47
- channels={3}
48
- data={[
49
- [1, 1, 2],
50
- [1, 1, 3],
51
- ]}
52
- />
53
- <MBArray
54
- items={1}
55
- channels={3}
56
- data={[
57
- [1, 1, -2],
58
- [1, 1, -3],
59
- ]}
60
- />
61
- <Point points={data} {...otherArgs} />
62
- </Cartesian>
63
- </Mathbox>
64
- )
65
- }
66
-
67
- export const DefaultPoint = Template.bind({})
68
- DefaultPoint.args = {}
69
-
70
- export const LiveProps = Template.bind({})
71
- LiveProps.args = {
72
- liveProps: {
73
- size: (t: number) => 20 * (1 + 0.5 * Math.sin(t)),
74
- },
75
- }
@@ -1,33 +0,0 @@
1
- import React, { useMemo, useCallback } from "react"
2
- import { MathboxSelection } from "mathbox"
3
- import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
4
- import { ContainedMathbox } from "../components"
5
-
6
- type MathboxProps = React.ComponentProps<typeof ContainedMathbox>
7
-
8
- const storybookDefaultMathboxOptions = {
9
- plugins: ["core", "controls", "cursor"],
10
- controls: {
11
- klass: OrbitControls,
12
- },
13
- }
14
-
15
- export const CustomMathbox = (props: MathboxProps) => {
16
- const { options: overrides, ...others } = props
17
- const options = useMemo(
18
- () => ({
19
- ...storybookDefaultMathboxOptions,
20
- ...(overrides ?? {}),
21
- }),
22
- [overrides]
23
- )
24
- const setup = useCallback((mathbox: MathboxSelection<"root"> | null) => {
25
- if (mathbox === null) return
26
- mathbox.three.camera.position.set(1, 1, 2)
27
- }, [])
28
- return (
29
- <ContainedMathbox ref={setup} options={options} {...others}>
30
- {props.children}
31
- </ContainedMathbox>
32
- )
33
- }
package/src/testSetup.ts DELETED
@@ -1,3 +0,0 @@
1
- import { getMockContext } from "./testUtils"
2
-
3
- HTMLCanvasElement.prototype.getContext = getMockContext
package/src/testUtils.ts DELETED
@@ -1,46 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- type Automock = any
3
-
4
- /**
5
- * A mock that uses proxies to create properties as they are accessed. Supports
6
- * function calls and toPrimitive.
7
- *
8
- * @param specifics Allows specifying specific values for properties. If a prop
9
- * exists on `specifics`, then that value will be used when the property is
10
- * accessed on automock.
11
- * @returns
12
- */
13
- const getAutomock = <T extends Record<string | symbol, unknown>>(
14
- specifics?: T
15
- ): Automock => {
16
- const autmockSeed = jest.fn()
17
- const handler = {
18
- get(target: Automock, prop: string | symbol) {
19
- if (prop === Symbol.toPrimitive) {
20
- return () => `Automock: ${JSON.stringify(specifics)}`
21
- }
22
- if (specifics && Reflect.has(specifics, prop)) {
23
- const value = Reflect.get(specifics, prop)
24
- return value
25
- }
26
- if (!Reflect.has(target, prop)) {
27
- Reflect.set(target, prop, getAutomock())
28
- }
29
- return Reflect.get(target, prop)
30
- },
31
- apply() {
32
- return getAutomock()
33
- },
34
- }
35
- return new Proxy(autmockSeed, handler)
36
- }
37
-
38
- export const getMockContext = () => {
39
- const mockContext = getAutomock({
40
- getParameter: jest.fn((name) => {
41
- if (name === mockContext.VERSION) return "Fake version!"
42
- return getAutomock()
43
- }),
44
- })
45
- return mockContext
46
- }
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "esModuleInterop": true,
4
- "strict": true,
5
- "jsx": "react",
6
- "module": "ESNext",
7
- "declaration": true,
8
- "declarationDir": "types",
9
- "sourceMap": true,
10
- "outDir": "build",
11
- "moduleResolution": "node",
12
- "emitDeclarationOnly": true,
13
- "allowSyntheticDefaultImports": true,
14
- "forceConsistentCasingInFileNames": true
15
- },
16
- "exclude": ["dist", "node_modules"]
17
- }
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "./tsconfig.base.json",
3
- "include": ["src/"],
4
- "exclude": ["src/**/*.test.tsx", "src/**/*.stories.tsx"]
5
- }