@jsenv/navi 0.26.1 → 0.26.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.
@@ -6650,14 +6650,7 @@ const CONTENT_PROPS = {
6650
6650
  };
6651
6651
  },
6652
6652
  spacing: (value, { boxFlow }) => {
6653
- if (
6654
- boxFlow === "flex-x" ||
6655
- boxFlow === "flex-y" ||
6656
- boxFlow === "inline-flex-x" ||
6657
- boxFlow === "inline-flex-y" ||
6658
- boxFlow === "grid" ||
6659
- boxFlow === "inline-grid"
6660
- ) {
6653
+ if (isSpacingHandledByFlow(boxFlow)) {
6661
6654
  return {
6662
6655
  gap: resolveSpacingSize(value, "gap"),
6663
6656
  };
@@ -6691,6 +6684,18 @@ const CONTENT_PROPS = {
6691
6684
  return undefined;
6692
6685
  },
6693
6686
  };
6687
+ const flowSpacingHandlerSet = new Set([
6688
+ "flex-x",
6689
+ "flex-y",
6690
+ "inline-flex-x",
6691
+ "inline-flex-y",
6692
+ "grid",
6693
+ "inline-grid",
6694
+ ]);
6695
+ const isSpacingHandledByFlow = (boxFlow) => {
6696
+ return flowSpacingHandlerSet.has(boxFlow);
6697
+ };
6698
+
6694
6699
  const All_PROPS = {
6695
6700
  ...FLOW_PROPS,
6696
6701
  ...OUTER_SPACING_PROPS,
@@ -6836,9 +6841,9 @@ const TYPO_SIZE_MAP = {
6836
6841
  xxl: "var(--navi-typo-xxl)",
6837
6842
  };
6838
6843
  Object.assign(TYPO_SIZE_MAP, negativeEntries(TYPO_SIZE_MAP));
6839
- const sizeSpacingScaleKeys = new Set(Object.keys(SIZE_MAP));
6840
- const isSizeSpacingScaleKey = (key) => {
6841
- return sizeSpacingScaleKeys.has(key);
6844
+ const sizeSpacingKeySet = new Set(Object.keys(SIZE_MAP));
6845
+ const isSizeSpacingKey = (key) => {
6846
+ return sizeSpacingKeySet.has(key);
6842
6847
  };
6843
6848
  const resolveSpacingSize = (size, property = "padding") => {
6844
6849
  return stringifyStyle(SIZE_MAP[size] || size, property);
@@ -8286,6 +8291,8 @@ const Box = props => {
8286
8291
  const ref = props.ref || defaultRef;
8287
8292
  const TagName = as;
8288
8293
  const defaultDisplay = getDefaultDisplay(TagName);
8294
+ // Read the parent flow early so we can use it when display="inherit" is requested.
8295
+ const parentBoxFlow = useContext(BoxFlowContext);
8289
8296
  let {
8290
8297
  inline,
8291
8298
  block,
@@ -8353,6 +8360,12 @@ const Box = props => {
8353
8360
  } else {
8354
8361
  boxFlow = defaultDisplay;
8355
8362
  }
8363
+ // When display="inherit" is passed, adopt the parent's flow instead of computing one.
8364
+ // This lets a child Box mirror its parent's flex/grid/block layout without repeating
8365
+ // the same layout props, and is used e.g. by Button's inner content element.
8366
+ if (rest.display === "inherit") {
8367
+ boxFlow = parentBoxFlow;
8368
+ }
8356
8369
  const boxFlowIsDefault = boxFlow === defaultDisplay;
8357
8370
  const remainingPropKeySet = new Set(Object.keys(rest));
8358
8371
  // some props not destructured but that are neither
@@ -8362,7 +8375,6 @@ const Box = props => {
8362
8375
  const selfForwardedProps = {};
8363
8376
  const childForwardedProps = {};
8364
8377
  {
8365
- const parentBoxFlow = useContext(BoxFlowContext);
8366
8378
  const styleDeps = [
8367
8379
  // Layout and alignment props
8368
8380
  parentBoxFlow, boxFlow,
@@ -20962,6 +20974,13 @@ const CustomWidthSpace = ({
20962
20974
  useRealSpaceChar
20963
20975
  }) => {
20964
20976
  if (useRealSpaceChar) {
20977
+ // Two-span trick: we want a real space character in the DOM so that
20978
+ // copy-pasting the text produces an actual space, but we also want
20979
+ // full control over the visual width of that gap.
20980
+ // - First span: contains the real space but rendered at font-size:0 so it
20981
+ // takes up zero visual space.
20982
+ // - Second span: a zero-width joiner (​) with padding-left set to
20983
+ // the desired gap size. This is the only visible part.
20965
20984
  return jsxs("span", {
20966
20985
  children: [jsx("span", {
20967
20986
  style: "font-size: 0",
@@ -20994,7 +21013,13 @@ const applySpacingOnTextChildren = (children, spacing, defaultSpace) => {
20994
21013
  if (spacing === REGULAR_SPACE || spacing === FAKE_SPACE) {
20995
21014
  separator = defaultSpace;
20996
21015
  } else if (typeof spacing === "string") {
20997
- if (isSizeSpacingScaleKey(spacing) || hasCSSSizeUnit(spacing) || spacing.startsWith("var(")) {
21016
+ if (isSizeSpacingKey(spacing)) {
21017
+ const value = resolveSpacingSize(spacing);
21018
+ separator = jsx(CustomWidthSpace, {
21019
+ value: value,
21020
+ useRealSpaceChar: useRealSpaceChar
21021
+ });
21022
+ } else if (hasCSSSizeUnit(spacing) || spacing.startsWith("var(")) {
20998
21023
  separator = jsx(CustomWidthSpace, {
20999
21024
  value: spacing,
21000
21025
  useRealSpaceChar: useRealSpaceChar
@@ -21164,6 +21189,7 @@ const TextUI = props => {
21164
21189
  childrenOutsideFlow,
21165
21190
  ...rest
21166
21191
  } = props;
21192
+ const parentBoxFlow = useContext(BoxFlowContext);
21167
21193
  const defaultSpace = preventSpaceUnderlines ? FAKE_SPACE : REGULAR_SPACE;
21168
21194
  const resolvedSpacing = spacing ?? defaultSpace;
21169
21195
  const boxProps = {
@@ -21173,7 +21199,7 @@ const TextUI = props => {
21173
21199
  ref,
21174
21200
  "baseClassName": withPropsClassName("navi_text", rest.baseClassName)
21175
21201
  };
21176
- const shouldPreserveSpacing = rest.as === "pre" || rest.flex || rest.grid;
21202
+ const shouldPreserveSpacing = rest.as === "pre" || rest.flex || rest.grid || isSpacingHandledByFlow(parentBoxFlow);
21177
21203
  if (shouldPreserveSpacing) {
21178
21204
  boxProps.spacing = resolvedSpacing;
21179
21205
  } else {
@@ -22782,7 +22808,9 @@ const ButtonDispatcher = props => {
22782
22808
  });
22783
22809
  };
22784
22810
  const ButtonUI = props => {
22811
+ import.meta.css = [css$x, "@jsenv/navi/src/field/button.jsx"];
22785
22812
  const {
22813
+ ref,
22786
22814
  readOnly,
22787
22815
  disabled,
22788
22816
  loading,
@@ -22799,13 +22827,10 @@ const ButtonUI = props => {
22799
22827
  children,
22800
22828
  ...rest
22801
22829
  } = props;
22802
- import.meta.css = [css$x, "@jsenv/navi/src/field/button.jsx"];
22803
22830
  const contextLoading = useContext(LoadingContext);
22804
22831
  const contextLoadingElement = useContext(LoadingElementContext);
22805
22832
  const contextReadOnly = useContext(ReadOnlyContext);
22806
22833
  const contextDisabled = useContext(DisabledContext);
22807
- const defaultRef = useRef();
22808
- const ref = props.ref || defaultRef;
22809
22834
  useAutoFocus(ref, autoFocus);
22810
22835
  const remainingProps = useConstraints(ref, rest);
22811
22836
  const innerLoading = loading || contextLoading && contextLoadingElement === ref.current;
@@ -22830,6 +22855,7 @@ const ButtonUI = props => {
22830
22855
  const renderButtonContent = buttonProps => {
22831
22856
  return jsxs(Text, {
22832
22857
  ...buttonProps,
22858
+ display: "inherit",
22833
22859
  spacing: spacing,
22834
22860
  className: "navi_button_content",
22835
22861
  children: [children, jsx(ButtonShadow, {})]
@@ -22839,6 +22865,7 @@ const ButtonUI = props => {
22839
22865
  return jsxs(Box, {
22840
22866
  "data-readonly-silent": innerLoading ? "" : undefined,
22841
22867
  ...remainingProps,
22868
+ ref: ref,
22842
22869
  autFocus: undefined // See use_auto_focus.js
22843
22870
  ,
22844
22871
 
@@ -22846,7 +22873,6 @@ const ButtonUI = props => {
22846
22873
  href: href,
22847
22874
  target: innerTarget,
22848
22875
  rel: innerRel,
22849
- ref: ref,
22850
22876
  onContextMenu: e => {
22851
22877
  if (as === "a") {
22852
22878
  // For link we keep context menu to allow "open in new tab" and other browser features