Skip to content

Commit

Permalink
Fix circular imports in forms package. This resolves a problem where …
Browse files Browse the repository at this point in the history
…Rollup's watch mode wasn't working.
  • Loading branch information
danielnaab committed Nov 1, 2024
1 parent 63a1ae5 commit efa9235
Show file tree
Hide file tree
Showing 27 changed files with 702 additions and 745 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useRef, useEffect } from 'react';
import { useFormManagerStore } from '../../../store.js';
import styles from '../../formEditStyles.module.css';
import type { Pattern } from '@atj/forms';

interface MovePatternDropdownProps {
isFieldset: boolean;
Expand All @@ -27,7 +28,9 @@ const MovePatternDropdown: React.FC<MovePatternDropdownProps> = ({
const dropdownRef = useRef<HTMLDivElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const pages = useFormManagerStore(state =>
Object.values(state.session.form.patterns).filter(p => p.type === 'page')
Object.values<Pattern>(state.session.form.patterns).filter(
p => p.type === 'page'
)
);
const movePatternToPage = useFormManagerStore(state => state.movePattern);
const focusPatternId = useFormManagerStore(state => state.focus?.pattern.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classNames from 'classnames';
import { useFormManagerStore } from '../../../store.js';
import MovePatternDropdown from './MovePatternDropdown.js';
import styles from '../../formEditStyles.module.css';
import type { Pattern } from '@atj/forms';

type PatternEditActionsProps = PropsWithChildren<{
children?: ReactElement;
Expand All @@ -19,7 +20,7 @@ export const PatternEditActions = ({ children }: PatternEditActionsProps) => {
state => state.focus?.pattern.type
);
const patterns = useFormManagerStore(state =>
Object.values(state.session.form.patterns)
Object.values<Pattern>(state.session.form.patterns)
);
const focusPatternId = useFormManagerStore(state => state.focus?.pattern.id);
const isPatternInFieldset = useMemo(() => {
Expand All @@ -34,10 +35,12 @@ export const PatternEditActions = ({ children }: PatternEditActionsProps) => {
copyPattern: state.copyPattern,
}));
const pages = useFormManagerStore(state =>
Object.values(state.session.form.patterns).filter(p => p.type === 'page')
Object.values<Pattern>(state.session.form.patterns).filter(
p => p.type === 'page'
)
);
const fieldsets = useFormManagerStore(state =>
Object.values(state.session.form.patterns).filter(
Object.values<Pattern>(state.session.form.patterns).filter(
p => p.type === 'fieldset'
)
);
Expand Down
5 changes: 5 additions & 0 deletions packages/forms/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { watch } from 'rollup';
import { builtinModules } from 'module';

import { nodeResolve } from '@rollup/plugin-node-resolve';
Expand Down Expand Up @@ -51,4 +52,8 @@ export default {
]),
];
})(),
watch: {
include: 'src/**/*.ts',
clearScreen: false,
},
};
Loading

0 comments on commit efa9235

Please sign in to comment.