@lark-apaas/coding-registry-buildless 0.1.2 → 0.1.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.
@@ -17,7 +17,13 @@
17
17
  //
18
18
  // Artboards are static design frames, not scroll regions — never use
19
19
  // height: 100% + overflow: auto/scroll on inner elements; size each artboard
20
- // to fit its content (explicit pixel height, or let it grow).
20
+ // to fit its content. Height behavior:
21
+ // • omit height → the card grows to fit its content (no vertical clipping);
22
+ // this is the right default for full pages / long screens.
23
+ // • height={N} → a fixed N-px frame that CLIPS overflow (overflow:hidden) —
24
+ // use only for deliberately cropped thumbnails (e.g. A/B tiles).
25
+ // width is always a fixed frame width (default 260); content wider than it is
26
+ // clipped, so set width to the real design width for full pages.
21
27
  //
22
28
  // When placing a device frame inside a DCArtboard, pass chromeless to
23
29
  // suppress the card chrome and let the artboard size to its content:
@@ -930,7 +936,12 @@ async function dcExport(node, w, h, name, kind) {
930
936
  }
931
937
 
932
938
  function DCArtboardFrame({ sectionId, artboard, label, order, onRename, onReorder, onFocus, onDelete }) {
933
- const { id: rawId, label: rawLabel, width = 260, height = 480, chromeless = false, children, style = {} } = artboard.props;
939
+ // Read height off the raw props (not a destructure default) so an *absent*
940
+ // height can opt into auto-grow while an explicit height={N} — even 480 —
941
+ // still means a fixed, content-clipping frame (thumbnail semantics).
942
+ const { id: rawId, label: rawLabel, width = 260, chromeless = false, children, style = {} } = artboard.props;
943
+ const hasHeight = artboard.props.height != null;
944
+ const height = hasHeight ? artboard.props.height : undefined;
934
945
  const id = rawId ?? rawLabel;
935
946
  const ref = React.useRef(null);
936
947
  const cardRef = React.useRef(null);
@@ -1056,8 +1067,17 @@ function DCArtboardFrame({ sectionId, artboard, label, order, onRename, onReorde
1056
1067
  </div>
1057
1068
  </div>
1058
1069
  <div ref={cardRef} className={"dc-card" + (chromeless ? ' chromeless' : '')}
1059
- style={{ ...(chromeless ? {} : { width, height, borderRadius: 4, border: '1px solid #DEE0E3', overflow: 'hidden', background: '#fff' }), ...style }}>
1060
- {children || <div style={{ height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#bbb', fontSize: 13, fontFamily: DC.font }}>{id}</div>}
1070
+ style={{ ...(chromeless ? {} : {
1071
+ width,
1072
+ // explicit height → fixed frame (overflow:hidden clips a tall page);
1073
+ // no height → the box grows to its content height. overflow:hidden
1074
+ // stays either way so the rounded corners clip and content wider than
1075
+ // the frame is trimmed to `width`; with auto height nothing is clipped
1076
+ // vertically because the box is exactly the content height.
1077
+ ...(hasHeight ? { height } : {}),
1078
+ borderRadius: 4, border: '1px solid #DEE0E3', overflow: 'hidden', background: '#fff',
1079
+ }), ...style }}>
1080
+ {children || <div style={{ minHeight: 160, height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#bbb', fontSize: 13, fontFamily: DC.font }}>{id}</div>}
1061
1081
  </div>
1062
1082
  </div>
1063
1083
  );
@@ -1112,27 +1132,29 @@ function DCFocusOverlay({ entry, sectionMeta, sectionOrder }) {
1112
1132
  return () => document.removeEventListener('keydown', k);
1113
1133
  });
1114
1134
 
1115
- const { width = 260, height = 480, chromeless = false, children } = artboard.props;
1116
- // width/height describe a fixed-frame (non-chromeless) card and are used
1117
- // directly for it. A chromeless artboard has NO fixed frame — its canvas
1118
- // card sizes to the content (a device frame, an auto-sized layout), so
1119
- // width/height fall back to 260×480 here and DON'T describe the content.
1120
- // Fitting to those defaults would wrap the real content (e.g. a 402×874
1121
- // device) in a 260×480 clip box and magnify the clipped slice. So for a
1122
- // chromeless artboard, measure the content's real rendered size first
1123
- // (unscaled, no clip) and fit-scale to that instead — mirroring how
1124
- // DCArtboardFrame lets a chromeless card size to its content.
1135
+ const { width = 260, chromeless = false, children } = artboard.props;
1136
+ const hasHeight = artboard.props.height != null;
1137
+ const height = hasHeight ? artboard.props.height : undefined;
1138
+ // A fixed-frame card (non-chromeless WITH an explicit height) uses width/
1139
+ // height directly. Otherwise the card has NO fixed height and its rendered
1140
+ // size describes the content, not a frame — either a chromeless artboard
1141
+ // (device frame / auto layout, both axes intrinsic) or a non-chromeless
1142
+ // artboard that omitted height and grows to its content (frame `width`, auto
1143
+ // height). Fitting such content to a default height would wrap it in an
1144
+ // undersized clip box and magnify the clipped slice — so measure the real
1145
+ // rendered size first and fit-scale to that, mirroring the canvas card.
1146
+ const autoSize = chromeless || !hasHeight;
1125
1147
  const measureRef = React.useRef(null);
1126
1148
  const [nat, setNat] = React.useState(null); // { aid, w, h } measured natural size
1127
1149
  React.useLayoutEffect(() => {
1128
- if (!chromeless) return;
1150
+ if (!autoSize) return;
1129
1151
  const el = measureRef.current;
1130
1152
  if (el) setNat({ aid, w: el.offsetWidth, h: el.offsetHeight });
1131
- }, [aid, chromeless]);
1132
- const useMeasured = chromeless && nat && nat.aid === aid && nat.w > 0;
1133
- const needsMeasure = chromeless && !useMeasured;
1153
+ }, [aid, autoSize]);
1154
+ const useMeasured = autoSize && nat && nat.aid === aid && nat.w > 0;
1155
+ const needsMeasure = autoSize && !useMeasured;
1134
1156
  const cw = useMeasured ? nat.w : width;
1135
- const ch = useMeasured ? nat.h : height;
1157
+ const ch = useMeasured ? nat.h : (height ?? 480);
1136
1158
 
1137
1159
  const [vp, setVp] = React.useState({ w: window.innerWidth, h: window.innerHeight });
1138
1160
  React.useEffect(() => { const r = () => setVp({ w: window.innerWidth, h: window.innerHeight }); window.addEventListener('resize', r); return () => window.removeEventListener('resize', r); }, []);
@@ -1180,20 +1202,21 @@ function DCFocusOverlay({ entry, sectionMeta, sectionOrder }) {
1180
1202
  exits focus. */}
1181
1203
  <div ref={contentRef} className="dc-focus-content" onClick={(e) => e.stopPropagation()}
1182
1204
  style={{ width: cw * scale, height: ch * scale, position: 'relative',
1183
- // hidden until the (chromeless) measure pass below reports the real size
1205
+ // hidden until the auto-size measure pass below reports the real size
1184
1206
  visibility: needsMeasure ? 'hidden' : 'visible' }}>
1185
- {/* Chromeless renders a hidden measure pass first (inline-block →
1186
- natural size for offsetWidth/Height), then re-renders scaled. Card
1187
- chrome (bg / radius / shadow / overflow:auto) is added only for a
1188
- fixed-frame box — matching the canvas card — and gives that box a
1189
- scroll viewport so content it clips (taller/wider than the frame) is
1190
- reachable; scrollbars are hidden by the .dc-focus-content CSS. A
1191
- chromeless box carries none of it, so its content owns its look. */}
1207
+ {/* Auto-size cards render a hidden measure pass first, then re-render
1208
+ scaled. Chromeless measures both axes (inline-block → intrinsic
1209
+ size); a non-chromeless auto card keeps its frame `width` and lets
1210
+ height run natural. Card chrome (bg / radius / shadow / overflow:auto)
1211
+ is added only for a non-chromeless box — matching the canvas card —
1212
+ giving it a scroll viewport for anything it still clips; scrollbars
1213
+ are hidden by the .dc-focus-content CSS. A chromeless box carries
1214
+ none of it, so its content owns its look. */}
1192
1215
  <div ref={measureRef} style={needsMeasure
1193
- ? { display: 'inline-block' }
1216
+ ? (chromeless ? { display: 'inline-block' } : { width })
1194
1217
  : { width: cw, height: ch, transform: `scale(${scale})`, transformOrigin: 'top left',
1195
1218
  ...(chromeless ? {} : { background: '#fff', borderRadius: 2, overflow: 'auto', boxShadow: '0 20px 80px rgba(0,0,0,.4)' }) }}>
1196
- {children || <div style={{ height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#bbb' }}>{aid}</div>}
1219
+ {children || <div style={{ minHeight: 160, height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#bbb' }}>{aid}</div>}
1197
1220
  </div>
1198
1221
  </div>
1199
1222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/coding-registry-buildless",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Miaoda registry (buildless runtime) — shadcn-style copy-in SDKs (globals + CDN-pinned, browser Babel) for buildless static HTML stacks",
5
5
  "type": "module",
6
6
  "files": [