@estiva-app/ui 0.43.0 → 0.44.0

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.
@@ -817,6 +817,12 @@ function standsInForAList(element) {
817
817
  return false;
818
818
  }
819
819
  var FILLS = /^(?:min-h-full|h-full)$/;
820
+ var CENTRES = /^(?:justify-center|items-center|content-center|place-(?:items|content)-center)$/;
821
+ var PADS = /^p[xytrblse]?-/;
822
+ function onlyElement(box) {
823
+ const kids = children2(box, "children").filter((kid) => !(kid.type === "JSXText" && !String(kid.value).trim()));
824
+ return kids.length === 1 && kids[0].type === "JSXElement" ? kids[0] : void 0;
825
+ }
820
826
  function isPageScope(opening) {
821
827
  const scope = attributeOf(opening, "scope");
822
828
  if (!scope) return true;
@@ -882,6 +888,7 @@ var noHandmadeEmptyState = {
882
888
  messages: {
883
889
  handmade: 'A line saying there is nothing is an EmptyState. Use `EmptyState` from @estiva-app/ui: `scope="section"` inside a section, `scope="page"` for a whole page.',
884
890
  wrongScope: 'A page-scope EmptyState inside a ScrollArea sits at the top of its pane, not the middle: the ScrollArea\'s content is only as tall as what is in it. Use `scope="section"` when the pane has anything else on it; when the whole pane is empty, draw the page EmptyState in place of the ScrollArea, not inside it.',
891
+ boxedPage: 'This box {{what}} a page-scope EmptyState, which centres itself in the room a flex column gives it and takes no padding. A box that places it can push it out of the middle, as the starter\'s home page did (UIG-10). Draw the EmptyState straight into the column, with `className="h-full"` outside a flex column.',
885
892
  wrongScopeVia: '`{{component}}` draws a page-scope EmptyState ({{where}}) inside this ScrollArea, where it sits at the top of its pane, not the middle: the ScrollArea\'s content is only as tall as what is in it. Use `scope="section"` there when the pane has anything else on it; when the whole pane is empty, draw the page EmptyState in place of the ScrollArea, not inside it.',
886
893
  ...ESCAPE_MESSAGES
887
894
  }
@@ -901,6 +908,20 @@ var noHandmadeEmptyState = {
901
908
  const opening = child2(element, "openingElement");
902
909
  const tag = tagName(element);
903
910
  if (tag && /^[a-z]/.test(tag)) {
911
+ const only = facts && onlyElement(element);
912
+ const inner = only && child2(only, "openingElement");
913
+ const spread = inner && children2(inner, "attributes").some((a) => a.type === "JSXSpreadAttribute");
914
+ if (inner && !spread && isPart(bindingOfTag(child2(inner, "name"), facts.locals), "EmptyState") && isPageScope(inner)) {
915
+ const className = attributeOf(opening, "className");
916
+ const own = className ? classesOf(child2(className, "value"), scopeOf).map((c) => c.replace(/^(?:[^:\s[\]]+:)+/, "")) : [];
917
+ const centres = own.some((c) => CENTRES.test(c));
918
+ const pads = own.some((c) => PADS.test(c));
919
+ if ((centres || pads) && !isEscaped(context, opening)) {
920
+ const what = centres && pads ? "centres and pads" : centres ? "centres" : "pads";
921
+ context.report({ loc: opening.loc, messageId: "boxedPage", data: { what } });
922
+ }
923
+ return;
924
+ }
904
925
  const words2 = onlyWords(element);
905
926
  if (!words2 || words2.length > SHORT) return;
906
927
  if (!standsInForAList(element)) return;