Skip to content

Commit

Permalink
Merge pull request chakra-ui#26 from chakra-ui/refactor/structure
Browse files Browse the repository at this point in the history
refactor: update package structure
  • Loading branch information
segunadebayo authored Nov 22, 2021
2 parents 7ac6e5a + 9c4022b commit 532c4b2
Show file tree
Hide file tree
Showing 273 changed files with 4,692 additions and 3,607 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"import/no-named-as-default": "off",
"prefer-object-spread": "off",
"arrow-body-style": "off",
"import/namespace": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:
uses: preactjs/compressed-size-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
pattern: "**/dist/**/*.prod.js"
pattern: "**/dist/**/*.mjs"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,5 @@ temp/
# End of https://www.toptal.com/developers/gitignore/api/node,yarn,jetbrains,visualstudiocode

# System files
.DS_Store
.DS_Store
.ultra.cache.json
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bracketSpacing": true,
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "always",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "all"
}
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
16 changes: 0 additions & 16 deletions babel.config.js

This file was deleted.

4 changes: 0 additions & 4 deletions examples/next-ts/.babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion examples/next-ts/components/state-visualizer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Machine } from "@ui-machines/core"
import { isDom } from "tiny-guard"
import { isDom } from "@ui-machines/utils"

type StateVisualizerProps = {
state: Record<string, any>
Expand Down
17 changes: 15 additions & 2 deletions examples/next-ts/next.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
const withPreconstruct = require("@preconstruct/next")
module.exports = withPreconstruct({})
module.exports = {
experimental: {
externalDir: true,
},
webpack: (config) => {
config.module.rules.push({
test: /\.m?js$/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
})
return config
},
}
12 changes: 5 additions & 7 deletions examples/next-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "with-typescript",
"name": "next-ts",
"version": "0.0.0",
"private": true,
"scripts": {
Expand All @@ -12,23 +12,21 @@
"dependencies": {
"@emotion/core": "^11.0.0",
"@emotion/styled": "^11.3.0",
"@reach/auto-id": "^0.15.0",
"@reach/portal": "^0.16.0",
"@reach/auto-id": "^0.16.0",
"@reach/portal": "^0.16.2",
"@ui-machines/core": "0.0.0",
"@ui-machines/react": "0.0.0",
"next": "latest",
"next": "^12.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.1",
"react-dom": "^17.0.2",
"react-spinners": "^0.11.0"
},
"devDependencies": {
"@preconstruct/next": "^3.0.0",
"@types/node": "16.9.1",
"@types/react": "^17.0.20",
"@types/react-dom": "^17.0.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"regenerator-runtime": "^0.13.9",
"typescript": "4.4.3"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { accordion } from "@ui-machines/accordion"
import { useMachine } from "@ui-machines/react"
import { accordion } from "@ui-machines/web"
import { StateVisualizer } from "components/state-visualizer"
import { useControls } from "hooks/use-controls"
import { useMount } from "hooks/use-mount"
Expand Down
6 changes: 2 additions & 4 deletions examples/next-ts/pages/combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import { combobox } from "@ui-machines/web"
import { useMachine } from "@ui-machines/react"

import * as styled from "@emotion/styled"

import { combobox } from "@ui-machines/combobox"
import { useMachine } from "@ui-machines/react"
import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { comboboxData } from "../../../shared/data"
Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Portal } from "@reach/portal"
import { dialog } from "@ui-machines/dialog"
import { useMachine, useSetup } from "@ui-machines/react"
import { dialog } from "@ui-machines/web"
import { StateVisualizer } from "components/state-visualizer"
import { useRef } from "react"

Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/editable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { editable } from "@ui-machines/editable"
import { useMachine, useSetup } from "@ui-machines/react"
import { editable } from "@ui-machines/web"
import { StateVisualizer } from "components/state-visualizer"
import { useControls } from "hooks/use-controls"

Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Global } from "@emotion/react"
import { useMachine } from "@ui-machines/react"
import { menu } from "@ui-machines/web"
import { menu } from "@ui-machines/menu"
import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { menuStyle } from "../../../shared/style"
Expand Down
13 changes: 8 additions & 5 deletions examples/next-ts/pages/nested-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useMachine } from "@ui-machines/react"
import { menu, mergeProps } from "@ui-machines/web"
import { menu } from "@ui-machines/menu"
import { mergeProps } from "@ui-machines/core"
// import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { useEffect } from "react"
import { nextTick } from "tiny-fn"
import { Styles } from "./menu"
import { nextTick } from "@ui-machines/dom-utils"
import { menuStyle } from "../../../shared/style"
import { Global } from "@emotion/react"

export default function Page() {
const [state, send, machine] = useMachine(menu.machine)
Expand Down Expand Up @@ -51,7 +53,8 @@ export default function Page() {
const triggerItem2Props = mergeProps(sub.getItemProps({ id: sub2.triggerProps.id }), sub2.triggerProps)

return (
<Styles>
<>
<Global styles={menuStyle} />
<button ref={rootRef} data-testid="trigger" {...root.triggerProps}>
Click me
</button>
Expand Down Expand Up @@ -119,6 +122,6 @@ export default function Page() {
{/* <StateVisualizer state={state} label="Root Machine" style={{ maxWidth: 320 }} />
<StateVisualizer state={subState} label="Sub Machine" style={{ maxWidth: 320, right: 420 }} />
<StateVisualizer state={sub2State} label="Sub2 Machine" style={{ maxWidth: 320, right: 800 }} /> */}
</Styles>
</>
)
}
6 changes: 3 additions & 3 deletions examples/next-ts/pages/number-input.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import { mergeProps, numberInput } from "@ui-machines/web"
import { mergeProps } from "@ui-machines/core"
import { numberInput } from "@ui-machines/number-input"
import { useMachine } from "@ui-machines/react"

import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { useControls } from "hooks/use-controls"
import { useMount } from "hooks/use-mount"

export default function Page() {
const controls = useControls({
Expand Down
7 changes: 3 additions & 4 deletions examples/next-ts/pages/pin-input.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { pinInput } from "@ui-machines/web"
import { Global } from "@emotion/react"
import { pinInput } from "@ui-machines/pin-input"
import { useMachine } from "@ui-machines/react"

import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { useControls } from "hooks/use-controls"
import { Global } from "@emotion/react"
import { useMount } from "hooks/use-mount"
import { pinInputStyle } from "../../../shared/style"

export default function Page() {
Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/popover.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Global } from "@emotion/react"
import { Portal } from "@reach/portal"
import { popover } from "@ui-machines/popover"
import { useMachine } from "@ui-machines/react"
import { popover } from "@ui-machines/web"
import { StateVisualizer } from "components/state-visualizer"
import { useControls } from "hooks/use-controls"
import { useMount } from "hooks/use-mount"
Expand Down
10 changes: 4 additions & 6 deletions examples/next-ts/pages/range-slider.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { rangeSlider } from "@ui-machines/web"
import { useMachine } from "@ui-machines/react"

import serialize from "form-serialize"
import * as styled from "@emotion/styled"

import { rangeSlider } from "@ui-machines/range-slider"
import { useMachine } from "@ui-machines/react"
import { StateVisualizer } from "components/state-visualizer"
import serialize from "form-serialize"
import { useMount } from "hooks/use-mount"
import { rangeSliderStyle } from "../../../shared/style"

const Styles = styled.default(`div`)(rangeSliderStyle as styled.CSSObject)
const Styles = styled.default(`div`)(rangeSliderStyle)

export default function Page() {
const [state, send] = useMachine(
Expand Down
3 changes: 1 addition & 2 deletions examples/next-ts/pages/rating.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { rating } from "@ui-machines/web"
import { rating } from "@ui-machines/rating"
import { useMachine } from "@ui-machines/react"

import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"

Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable jsx-a11y/label-has-associated-control */
import * as styled from "@emotion/styled"
import { useMachine } from "@ui-machines/react"
import { slider } from "@ui-machines/web"
import { slider } from "@ui-machines/slider"
import { StateVisualizer } from "components/state-visualizer"
import serialize from "form-serialize"
import { useMount } from "hooks/use-mount"
Expand Down
6 changes: 2 additions & 4 deletions examples/next-ts/pages/split-view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { splitView } from "@ui-machines/web"
import { useMachine } from "@ui-machines/react"

import * as styled from "@emotion/styled"

import { useMachine } from "@ui-machines/react"
import { splitView } from "@ui-machines/split-view"
import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { splitViewStyle } from "../../../shared/style"
Expand Down
4 changes: 2 additions & 2 deletions examples/next-ts/pages/tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { tabs } from "@ui-machines/web"
import { useMachine } from "@ui-machines/react"
import { tabs } from "@ui-machines/tabs"
import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { useControls } from "hooks/use-controls"
import { useMount } from "hooks/use-mount"

const tabsData = [
{
Expand Down
8 changes: 3 additions & 5 deletions examples/next-ts/pages/tags-input.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { tagsInput } from "@ui-machines/web"
import { useMachine } from "@ui-machines/react"

import * as styled from "@emotion/styled"

import { useMachine } from "@ui-machines/react"
import { tagsInput } from "@ui-machines/tags-input"
import { StateVisualizer } from "components/state-visualizer"
import { useControls } from "hooks/use-controls"
import { useMount } from "hooks/use-mount"
import { tagsInputStyle } from "../../../shared/style"
import { useControls } from "hooks/use-controls"

const Styles = styled.default(`div`)(tagsInputStyle as styled.CSSObject)

Expand Down
3 changes: 1 addition & 2 deletions examples/next-ts/pages/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { Global } from "@emotion/react"
import { useActor, useMachine } from "@ui-machines/react"
import { toast, ToastMachine } from "@ui-machines/web"
import { toast, ToastMachine } from "@ui-machines/toast"
import { StateVisualizer } from "components/state-visualizer"
import { useMount } from "hooks/use-mount"
import { useRef } from "react"
Expand All @@ -19,7 +19,6 @@ const Toast = ({ actor }: { actor: ToastMachine }) => {
<pre className="toast" {...t.containerProps}>
<progress max={ctx.progress?.max} value={ctx.progress?.value} />
<p>{ctx.title}</p>
{/* @ts-expect-error */}
<p>{ctx.type === "loading" ? <BeatLoader /> : null}</p>
<button onClick={t.dismiss}>Close</button>
</pre>
Expand Down
2 changes: 1 addition & 1 deletion examples/next-ts/pages/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMachine, useSetup } from "@ui-machines/react"
import { tooltip } from "@ui-machines/web"
import { tooltip } from "@ui-machines/tooltip"

function Tooltip(props: { id?: string }) {
const [state, send] = useMachine(tooltip.machine)
Expand Down
7 changes: 2 additions & 5 deletions examples/next-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
"strict": false,
"target": "esnext",
"baseUrl": ".",
"paths": {
"@ui-machines/core": ["../../packages/core/src"],
"@ui-machines/react": ["../../packages/frameworks/react/src"]
}
"incremental": true
},
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx", "next-env.d.ts"]
"include": ["**/*.ts", "**/*.tsx", "next-env.d.ts", "next.config.js"]
}
1 change: 1 addition & 0 deletions examples/solid-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "solid-ts",
"version": "0.0.0",
"description": "",
"private": true,
"scripts": {
"clean": "echo 'clean'",
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/components/state-visualizer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isDom } from "tiny-guard"
import { isDom } from "@ui-machines/utils"
import { Machine } from "@ui-machines/core"

type StateVisualizerProps = {
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/pages/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { accordion } from "@ui-machines/web"
import { accordion } from "@ui-machines/accordion"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"
import { createMemo } from "solid-js"
import { StateVisualizer } from "../components/state-visualizer"
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/pages/combobox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { combobox } from "@ui-machines/web"
import { combobox } from "@ui-machines/combobox"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"

import { createMemo, For } from "solid-js"
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/pages/editable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { editable } from "@ui-machines/web"
import { editable } from "@ui-machines/editable"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"
import { createMemo } from "solid-js"
import { StateVisualizer } from "../components/state-visualizer"
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/pages/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { menu } from "@ui-machines/web"
import { menu } from "@ui-machines/menu"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"

import { createMemo } from "solid-js"
Expand Down
7 changes: 3 additions & 4 deletions examples/solid-ts/src/pages/number-input.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { mergeProps, numberInput } from "@ui-machines/web"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"

import { mergeProps } from "@ui-machines/core"
import { numberInput } from "@ui-machines/number-input"
import { normalizeProps, SolidPropTypes, useMachine, useSetup } from "@ui-machines/solid"
import { createMemo } from "solid-js"

import { StateVisualizer } from "../components/state-visualizer"

export default function Page() {
Expand Down
2 changes: 1 addition & 1 deletion examples/solid-ts/src/pages/pin-input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pinInput } from "@ui-machines/web"
import { pinInput } from "@ui-machines/pin-input"
import { normalizeProps, useMachine, useSetup, SolidPropTypes } from "@ui-machines/solid"

import { createMemo } from "solid-js"
Expand Down
Loading

0 comments on commit 532c4b2

Please sign in to comment.