@structuralists/scaffolding 0.0.2 → 0.1.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 (67) hide show
  1. package/.storybook/main.ts +1 -1
  2. package/.storybook/preview.tsx +36 -1
  3. package/CLAUDE.md +25 -0
  4. package/bun.lock +211 -202
  5. package/eslint.config.mjs +85 -84
  6. package/package.json +21 -20
  7. package/roadmap.md +27 -0
  8. package/src/components/Chat/ChatComposer/ChatComposer.stories.tsx +1 -1
  9. package/src/components/Chat/ChatMessage/ChatMessage.stories.tsx +1 -1
  10. package/src/components/Chat/ChatRecipientsHeader/ChatRecipientsHeader.stories.tsx +1 -1
  11. package/src/components/Chat/ChatShell/ChatShell.stories.tsx +1 -1
  12. package/src/components/Chat/PillCombobox/PillCombobox.stories.tsx +1 -1
  13. package/src/components/Content/Badge/Badge.stories.tsx +1 -1
  14. package/src/components/Content/Card/Card.stories.tsx +1 -1
  15. package/src/components/Content/EditableMarkdown/EditableMarkdown.stories.tsx +1 -1
  16. package/src/components/Content/Heading/Heading.stories.tsx +1 -1
  17. package/src/components/Content/Link/Link.stories.tsx +1 -1
  18. package/src/components/Content/List/List.stories.tsx +1 -1
  19. package/src/components/Content/LoadingContainer/LoadingContainer.stories.tsx +1 -1
  20. package/src/components/Content/Markdown/Markdown.stories.tsx +1 -1
  21. package/src/components/Content/Menu/Menu.stories.tsx +1 -1
  22. package/src/components/Content/Text/Text.stories.tsx +1 -1
  23. package/src/components/Forms/Button/Button.stories.tsx +1 -1
  24. package/src/components/Forms/Field/Field.stories.tsx +1 -1
  25. package/src/components/Forms/IconButton/IconButton.stories.tsx +1 -1
  26. package/src/components/Forms/Input/Input.stories.tsx +1 -1
  27. package/src/components/Forms/Select/MultiSelect/MultiSelect.stories.tsx +1 -1
  28. package/src/components/Forms/Select/SingleSelect/SingleSelect.stories.tsx +1 -1
  29. package/src/components/Forms/Textarea/Textarea.stories.tsx +1 -1
  30. package/src/components/Json/Json/Json.stories.tsx +1 -1
  31. package/src/components/Json/JsonTable/JsonTable.stories.tsx +1 -1
  32. package/src/components/Layout/Bar/Bar.stories.tsx +1 -1
  33. package/src/components/Layout/Debug/Debug.stories.tsx +1 -1
  34. package/src/components/Layout/Divider/Divider.stories.tsx +1 -1
  35. package/src/components/Layout/Grid/Grid.stories.tsx +1 -1
  36. package/src/components/Layout/Panels/Panels.stories.tsx +47 -1
  37. package/src/components/Layout/Panels/index.tsx +17 -1
  38. package/src/components/Layout/Panels/types.ts +5 -0
  39. package/src/components/Layout/Stack/Stack.stories.tsx +1 -1
  40. package/src/components/Modals/ConfirmModal/ConfirmModal.stories.tsx +1 -1
  41. package/src/components/Modals/LargeModal/LargeModal.stories.tsx +1 -1
  42. package/src/components/Modals/MediumModal/MediumModal.stories.tsx +1 -1
  43. package/src/components/Navigation/TabBar/TabBar.stories.tsx +1 -1
  44. package/src/components/Navigation/VerticalNav/VerticalNav.stories.tsx +1 -1
  45. package/src/components/Overlays/Popover/Popover.stories.tsx +1 -1
  46. package/src/components/Overlays/Tooltip/Tooltip.stories.tsx +1 -1
  47. package/src/components/Primitives/EmptyValue/EmptyValue.stories.tsx +1 -1
  48. package/src/components/Primitives/LinedStack/LinedStack.stories.tsx +1 -1
  49. package/src/components/Primitives/LongText/LongText.stories.tsx +1 -1
  50. package/src/components/Primitives/Num/Num.stories.tsx +1 -1
  51. package/src/components/Primitives/Percent/Percent.stories.tsx +1 -1
  52. package/src/components/Primitives/RelativeTime/RelativeTime.stories.tsx +1 -1
  53. package/src/components/Tables/BigTable/BigTable.stories.tsx +1 -1
  54. package/src/components/Tables/QuickTable/QuickTable.stories.tsx +1 -1
  55. package/src/forms/CLAUDE.md +144 -0
  56. package/src/forms/path/path.ts +50 -0
  57. package/src/forms/path/types.test-d.ts +175 -0
  58. package/src/forms/path/types.ts +35 -0
  59. package/src/forms/useFormState/types.ts +13 -0
  60. package/src/forms/useFormState/useFormState.ts +14 -0
  61. package/src/forms/validations/types.test-d.ts +26 -0
  62. package/src/forms/validations/types.ts +15 -0
  63. package/src/hooks/useClickOutside/index.ts +57 -0
  64. package/src/hooks/useStableCallback/index.ts +36 -0
  65. package/src/index.ts +2 -0
  66. package/src/storybook/Composition.stories.tsx +1 -1
  67. package/src/storybook/_StoryUtils.stories.tsx +1 -1
@@ -3,7 +3,7 @@ import type { StorybookConfig } from '@storybook/react-vite';
3
3
  const config: StorybookConfig = {
4
4
  framework: '@storybook/react-vite',
5
5
  stories: ['../src/**/*.stories.@(ts|tsx)'],
6
- addons: ['@storybook/addon-essentials', '@storybook/addon-storysource'],
6
+ addons: ['@storybook/addon-docs'],
7
7
  };
8
8
 
9
9
  export default config;
@@ -1,10 +1,45 @@
1
- import type { Preview } from '@storybook/react';
1
+ import type { Preview } from '@storybook/react-vite';
2
2
  import { MemoryRouter } from 'react-router';
3
+ import * as prettier from 'prettier/standalone';
4
+ import * as babel from 'prettier/plugins/babel';
5
+ import * as estree from 'prettier/plugins/estree';
3
6
  import '../tokens.css';
4
7
 
8
+ // Storybook's useTransformCode re-invokes transform on every render with no
9
+ // dep array; memoizing by input lets cache hits return a string synchronously
10
+ // and skip the "Transforming..." placeholder that causes the flicker.
11
+ const formatCache = new Map<string, string>();
12
+
5
13
  const preview: Preview = {
6
14
  parameters: {
7
15
  layout: 'padded',
16
+
17
+ docs: {
18
+ codePanel: true,
19
+ source: {
20
+ type: 'dynamic',
21
+ transform: (code: string) => {
22
+ const cached = formatCache.get(code);
23
+ if (cached !== undefined) return cached;
24
+
25
+ return prettier
26
+ .format(code, {
27
+ parser: 'babel',
28
+ plugins: [babel, estree],
29
+ printWidth: 80,
30
+ singleQuote: true,
31
+ })
32
+ .then((formatted) => {
33
+ formatCache.set(code, formatted);
34
+ return formatted;
35
+ })
36
+ .catch(() => {
37
+ formatCache.set(code, code);
38
+ return code;
39
+ });
40
+ },
41
+ },
42
+ }
8
43
  },
9
44
  decorators: [
10
45
  (Story) => (
package/CLAUDE.md CHANGED
@@ -28,3 +28,28 @@ export const Foo = ({ a, b, c }: FooProps) => {
28
28
  Why: the destructuring line at the top of the body acts as a quick legend
29
29
  of what the component reads from its props, scannable without parsing the
30
30
  function signature. Keeps the call shape uniform across the package.
31
+
32
+ ### Custom hook arguments
33
+
34
+ Project-defined hooks must take a single argument named `args` (an object)
35
+ and destructure on the first line of the function body — same shape as the
36
+ component-prop rule above.
37
+
38
+ ```ts
39
+ // ✅ correct
40
+ export const useFoo = (args: UseFooArgs) => {
41
+ const { a, b, c } = args;
42
+ // ...
43
+ };
44
+
45
+ // ❌ wrong — positional args
46
+ export const useFoo = (a: string, b: number, c?: boolean) => {
47
+ // ...
48
+ };
49
+ ```
50
+
51
+ Why: named args read clearly at the call site (`useFoo({ a, b })`), survive
52
+ reordering, and let new optional fields be added without breaking callers.
53
+ Built-in React hooks (`useState`, `useEffect`, etc.) keep their stock
54
+ positional signatures — this rule applies only to hooks defined in this
55
+ package.