@loykin/designkit 0.0.1 → 0.0.2

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.
package/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  React page template library. Provides ready-to-use page layouts for admin and dashboard applications.
4
4
 
5
- For AI-assisted implementation in consuming applications, see the
6
- [DesignKit Consumer Agent Guide](docs/consumer-guide.md).
5
+ For AI-assisted implementation in consuming applications, follow the published
6
+ compound-component contract below. The same rules are included in the package's
7
+ TypeScript declarations so editors and coding agents can discover them.
7
8
 
8
9
  ## Installation
9
10
 
@@ -59,6 +60,12 @@ export function UsersPage() {
59
60
 
60
61
  General-purpose page shell. Accepts `.Body`, `.Tab`, and `.Section` child slots which determine the layout mode automatically.
61
62
 
63
+ > **Compound-component contract:** `DataBodyTemplate` is the required root.
64
+ > Never render `.Group`, `.Tab`, `.Section`, `.Body`, `.Summary`, `.Row`, or
65
+ > `.Field` without it. Choose one primary mode—direct content/groups, `Tab`,
66
+ > `Section`, or `Body`—and do not mix those modes in one root. Invalid standalone
67
+ > usage throws at render time.
68
+
62
69
  ```tsx
63
70
  <DataBodyTemplate
64
71
  topBar={<PageTopBar left="Admin / Users" />}
@@ -142,6 +149,8 @@ Groups content within a tab or section. The `layout` prop controls the visual st
142
149
  | `inline` | Table-style rows (detail view) |
143
150
  | `split` | Left list + right detail |
144
151
 
152
+ `layout` defaults to `stacked`; omit it when the stacked arrangement is intended.
153
+
145
154
  | Prop | Type | Description |
146
155
  |---|---|---|
147
156
  | `layout` | `GroupLayout` | Visual structure — see table above |
@@ -153,16 +162,18 @@ Groups content within a tab or section. The `layout` prop controls the visual st
153
162
  | `className` | `string` | Class applied to the group root element |
154
163
 
155
164
  ```tsx
156
- <DataBodyTemplate.Tab id="settings" label="Settings">
157
- <DataBodyTemplate.Group layout="horizontal" title="Identity" description="Basic information">
158
- <DataBodyTemplate.Row label="Name" required>
159
- <Input defaultValue="Sarah Kim" />
160
- </DataBodyTemplate.Row>
161
- <DataBodyTemplate.Row label="Email">
162
- <Input type="email" defaultValue="sarah@acme.com" />
163
- </DataBodyTemplate.Row>
164
- </DataBodyTemplate.Group>
165
- </DataBodyTemplate.Tab>
165
+ <DataBodyTemplate title="Settings">
166
+ <DataBodyTemplate.Tab id="settings" label="Settings">
167
+ <DataBodyTemplate.Group layout="horizontal" title="Identity" description="Basic information">
168
+ <DataBodyTemplate.Row label="Name" required>
169
+ <Input defaultValue="Sarah Kim" />
170
+ </DataBodyTemplate.Row>
171
+ <DataBodyTemplate.Row label="Email">
172
+ <Input type="email" defaultValue="sarah@acme.com" />
173
+ </DataBodyTemplate.Row>
174
+ </DataBodyTemplate.Group>
175
+ </DataBodyTemplate.Tab>
176
+ </DataBodyTemplate>
166
177
  ```
167
178
 
168
179
  #### DataBodyTemplate.Field
@@ -170,10 +181,12 @@ Groups content within a tab or section. The `layout` prop controls the visual st
170
181
  Read-only key-value display.
171
182
 
172
183
  ```tsx
173
- <DataBodyTemplate.Group layout="inline" title="Identity">
174
- <DataBodyTemplate.Field label="Email">sarah@acme.com</DataBodyTemplate.Field>
175
- <DataBodyTemplate.Field label="Role"><Badge>Admin</Badge></DataBodyTemplate.Field>
176
- </DataBodyTemplate.Group>
184
+ <DataBodyTemplate title="Profile">
185
+ <DataBodyTemplate.Group layout="inline" title="Identity">
186
+ <DataBodyTemplate.Field label="Email">sarah@acme.com</DataBodyTemplate.Field>
187
+ <DataBodyTemplate.Field label="Role"><Badge>Admin</Badge></DataBodyTemplate.Field>
188
+ </DataBodyTemplate.Group>
189
+ </DataBodyTemplate>
177
190
  ```
178
191
 
179
192
  #### DataBodyTemplate.Summary
package/dist/index.cjs CHANGED
@@ -2786,19 +2786,30 @@ function WorkbenchBodyTemplate({
2786
2786
  ] })
2787
2787
  ] });
2788
2788
  }
2789
+ var DataBodyTemplateContext = React2__namespace.default.createContext(false);
2790
+ function useDataBodyTemplateParent(component) {
2791
+ if (!React2__namespace.default.useContext(DataBodyTemplateContext)) {
2792
+ throw new Error(
2793
+ `[DesignKit] <DataBodyTemplate.${component}> must be rendered inside <DataBodyTemplate>. Wrap it like: <DataBodyTemplate><DataBodyTemplate.${component}>...</DataBodyTemplate.${component}></DataBodyTemplate>.`
2794
+ );
2795
+ }
2796
+ }
2789
2797
  function DataBodyTab(_props) {
2798
+ useDataBodyTemplateParent("Tab");
2790
2799
  return null;
2791
2800
  }
2792
2801
  function isDataBodyTab(node) {
2793
2802
  return Boolean(node && typeof node === "object" && "type" in node && node.type === DataBodyTab);
2794
2803
  }
2795
2804
  function DataBodyBody(_props) {
2805
+ useDataBodyTemplateParent("Body");
2796
2806
  return null;
2797
2807
  }
2798
2808
  function isDataBodyBody(node) {
2799
2809
  return Boolean(node && typeof node === "object" && "type" in node && node.type === DataBodyBody);
2800
2810
  }
2801
2811
  function DataBodySection(_props) {
2812
+ useDataBodyTemplateParent("Section");
2802
2813
  return null;
2803
2814
  }
2804
2815
  function isDataBodySection(node) {
@@ -2807,6 +2818,7 @@ function isDataBodySection(node) {
2807
2818
  );
2808
2819
  }
2809
2820
  function DataBodySummary(_props) {
2821
+ useDataBodyTemplateParent("Summary");
2810
2822
  return null;
2811
2823
  }
2812
2824
  function isDataBodySummary(node) {
@@ -2821,6 +2833,7 @@ var layoutDefaultVariant = {
2821
2833
  split: "bordered"
2822
2834
  };
2823
2835
  function DataBodyGroup(props) {
2836
+ useDataBodyTemplateParent("Group");
2824
2837
  return renderGroupProps(props);
2825
2838
  }
2826
2839
  function isDataBodyGroup(node) {
@@ -2918,6 +2931,7 @@ function renderGroupProps(props) {
2918
2931
  ] });
2919
2932
  }
2920
2933
  function DataBodyField({ label, description, children }) {
2934
+ useDataBodyTemplateParent("Field");
2921
2935
  return /* @__PURE__ */ jsxRuntime.jsxs(
2922
2936
  "div",
2923
2937
  {
@@ -2934,6 +2948,7 @@ function DataBodyField({ label, description, children }) {
2934
2948
  );
2935
2949
  }
2936
2950
  function DataBodyRow({ label, description, required, children }) {
2951
+ useDataBodyTemplateParent("Row");
2937
2952
  return /* @__PURE__ */ jsxRuntime.jsxs(
2938
2953
  "div",
2939
2954
  {
@@ -2956,7 +2971,7 @@ function TopBarSlot({ topBar }) {
2956
2971
  if (!topBar) return null;
2957
2972
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: topBar });
2958
2973
  }
2959
- function Root2({
2974
+ function RootContent({
2960
2975
  theme,
2961
2976
  className,
2962
2977
  topBar,
@@ -3066,6 +3081,9 @@ function Root2({
3066
3081
  ] })
3067
3082
  ] });
3068
3083
  }
3084
+ function Root2(props) {
3085
+ return /* @__PURE__ */ jsxRuntime.jsx(DataBodyTemplateContext.Provider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(RootContent, { ...props }) });
3086
+ }
3069
3087
  var DataBodyTemplate = Object.assign(Root2, {
3070
3088
  Body: DataBodyBody,
3071
3089
  Tab: DataBodyTab,