@loykin/designkit 0.0.1 → 0.0.3

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/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) {
@@ -2814,6 +2826,56 @@ function isDataBodySummary(node) {
2814
2826
  node && typeof node === "object" && "type" in node && node.type === DataBodySummary
2815
2827
  );
2816
2828
  }
2829
+ function DataBodyResource({
2830
+ toolbarLeft,
2831
+ toolbarRight,
2832
+ refreshing,
2833
+ refreshingLabel = "Refreshing",
2834
+ notice,
2835
+ footer,
2836
+ children,
2837
+ className,
2838
+ bodyClassName
2839
+ }) {
2840
+ useDataBodyTemplateParent("Resource");
2841
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2842
+ "section",
2843
+ {
2844
+ "data-slot": "data-body-resource",
2845
+ "data-refreshing": refreshing ? "true" : "false",
2846
+ className: cn("flex min-h-0 flex-col", className),
2847
+ children: [
2848
+ (toolbarLeft || toolbarRight || refreshing) && /* @__PURE__ */ jsxRuntime.jsxs(DataPage.GroupToolbar, { children: [
2849
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: toolbarLeft }),
2850
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
2851
+ refreshing && /* @__PURE__ */ jsxRuntime.jsxs(
2852
+ "span",
2853
+ {
2854
+ className: "flex items-center gap-1.5 text-xs text-muted-foreground",
2855
+ role: "status",
2856
+ children: [
2857
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "size-3 animate-spin rounded-full border-2 border-muted border-t-primary" }),
2858
+ refreshingLabel
2859
+ ]
2860
+ }
2861
+ ),
2862
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.Actions, { children: toolbarRight })
2863
+ ] })
2864
+ ] }),
2865
+ notice && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3 shrink-0", children: notice }),
2866
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.GroupBody, { className: cn("min-h-0 flex-1", bodyClassName), children }),
2867
+ footer && /* @__PURE__ */ jsxRuntime.jsx(
2868
+ "div",
2869
+ {
2870
+ className: "mt-3 shrink-0 border-t border-border pt-3",
2871
+ "data-slot": "data-body-resource-footer",
2872
+ children: footer
2873
+ }
2874
+ )
2875
+ ]
2876
+ }
2877
+ );
2878
+ }
2817
2879
  var layoutDefaultVariant = {
2818
2880
  stacked: "plain",
2819
2881
  horizontal: "card",
@@ -2821,6 +2883,7 @@ var layoutDefaultVariant = {
2821
2883
  split: "bordered"
2822
2884
  };
2823
2885
  function DataBodyGroup(props) {
2886
+ useDataBodyTemplateParent("Group");
2824
2887
  return renderGroupProps(props);
2825
2888
  }
2826
2889
  function isDataBodyGroup(node) {
@@ -2918,6 +2981,7 @@ function renderGroupProps(props) {
2918
2981
  ] });
2919
2982
  }
2920
2983
  function DataBodyField({ label, description, children }) {
2984
+ useDataBodyTemplateParent("Field");
2921
2985
  return /* @__PURE__ */ jsxRuntime.jsxs(
2922
2986
  "div",
2923
2987
  {
@@ -2934,6 +2998,7 @@ function DataBodyField({ label, description, children }) {
2934
2998
  );
2935
2999
  }
2936
3000
  function DataBodyRow({ label, description, required, children }) {
3001
+ useDataBodyTemplateParent("Row");
2937
3002
  return /* @__PURE__ */ jsxRuntime.jsxs(
2938
3003
  "div",
2939
3004
  {
@@ -2956,7 +3021,7 @@ function TopBarSlot({ topBar }) {
2956
3021
  if (!topBar) return null;
2957
3022
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: topBar });
2958
3023
  }
2959
- function Root2({
3024
+ function RootContent({
2960
3025
  theme,
2961
3026
  className,
2962
3027
  topBar,
@@ -3000,7 +3065,13 @@ function Root2({
3000
3065
  /* @__PURE__ */ jsxRuntime.jsx(DataPage.Actions, { children: actions })
3001
3066
  ] }),
3002
3067
  summaryEl && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0 border-b border-border px-(--designkit-page-padding-x) py-(--designkit-panel-gap)", children: summaryEl.props.children }),
3003
- /* @__PURE__ */ jsxRuntime.jsx(DataPage.Content, { className: contentClassName, children: /* @__PURE__ */ jsxRuntime.jsx(DataPage.Group, { className: "h-full", children: /* @__PURE__ */ jsxRuntime.jsx(DataPage.GroupBody, { className: cn("h-full", bodyEl.props.className), children: bodyEl.props.children }) }) })
3068
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.Content, { className: contentClassName, children: /* @__PURE__ */ jsxRuntime.jsxs(DataPage.Group, { className: "flex h-full flex-col", children: [
3069
+ (toolbarLeft || toolbarRight) && /* @__PURE__ */ jsxRuntime.jsxs(DataPage.GroupToolbar, { children: [
3070
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 items-center gap-2", children: toolbarLeft }),
3071
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.Actions, { children: toolbarRight })
3072
+ ] }),
3073
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.GroupBody, { className: cn("min-h-0 flex-1", bodyEl.props.className), children: bodyEl.props.children })
3074
+ ] }) })
3004
3075
  ] });
3005
3076
  }
3006
3077
  if (hasSections) {
@@ -3039,6 +3110,8 @@ function Root2({
3039
3110
  ] });
3040
3111
  }
3041
3112
  const activeTabNode = tabs.find((tab) => tab.props.id === activeId) ?? tabs[0];
3113
+ const activeToolbarLeft = activeTabNode?.props.toolbarLeft ?? toolbarLeft;
3114
+ const activeToolbarRight = activeTabNode?.props.toolbarRight ?? toolbarRight;
3042
3115
  return /* @__PURE__ */ jsxRuntime.jsxs(DataPage, { className: cn("layout-databody", className), style: theme, children: [
3043
3116
  /* @__PURE__ */ jsxRuntime.jsx(TopBarSlot, { topBar }),
3044
3117
  /* @__PURE__ */ jsxRuntime.jsxs(DataPage.Header, { children: [
@@ -3058,19 +3131,24 @@ function Root2({
3058
3131
  tab.props.id
3059
3132
  )) }),
3060
3133
  /* @__PURE__ */ jsxRuntime.jsxs(DataPage.Content, { className: contentClassName, children: [
3061
- (toolbarLeft || toolbarRight) && /* @__PURE__ */ jsxRuntime.jsxs(DataPage.GroupToolbar, { children: [
3062
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 items-center gap-2", children: toolbarLeft }),
3063
- /* @__PURE__ */ jsxRuntime.jsx(DataPage.Actions, { children: toolbarRight })
3134
+ (activeToolbarLeft || activeToolbarRight) && /* @__PURE__ */ jsxRuntime.jsxs(DataPage.GroupToolbar, { children: [
3135
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 items-center gap-2", children: activeToolbarLeft }),
3136
+ /* @__PURE__ */ jsxRuntime.jsx(DataPage.Actions, { children: activeToolbarRight })
3064
3137
  ] }),
3065
3138
  hasTabs ? /* @__PURE__ */ jsxRuntime.jsx(DataPage.GroupBody, { className: "min-h-full", children: renderGroups(activeTabNode?.props.children) }) : /* @__PURE__ */ jsxRuntime.jsx(DataPage.GroupBody, { children: bodyChildren.map((child, i) => /* @__PURE__ */ jsxRuntime.jsx(React2.Fragment, { children: isDataBodyGroup(child) ? renderGroup(child) : child }, i)) })
3066
- ] })
3139
+ ] }),
3140
+ activeTabNode?.props.footer && /* @__PURE__ */ jsxRuntime.jsx(DataPage.Footer, { children: activeTabNode.props.footer })
3067
3141
  ] });
3068
3142
  }
3143
+ function Root2(props) {
3144
+ return /* @__PURE__ */ jsxRuntime.jsx(DataBodyTemplateContext.Provider, { value: true, children: /* @__PURE__ */ jsxRuntime.jsx(RootContent, { ...props }) });
3145
+ }
3069
3146
  var DataBodyTemplate = Object.assign(Root2, {
3070
3147
  Body: DataBodyBody,
3071
3148
  Tab: DataBodyTab,
3072
3149
  Section: DataBodySection,
3073
3150
  Summary: DataBodySummary,
3151
+ Resource: DataBodyResource,
3074
3152
  Group: DataBodyGroup,
3075
3153
  Row: DataBodyRow,
3076
3154
  Field: DataBodyField