@jsenv/navi 0.8.0 → 0.9.1

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.
@@ -18575,124 +18575,253 @@ const useConstraints = (elementRef, constraints, targetSelector) => {
18575
18575
  }, constraints);
18576
18576
  };
18577
18577
 
18578
+ const FlexDirectionContext = createContext();
18579
+
18578
18580
  /**
18579
- * Merges a component's base style with style received from props.
18580
- * Automatically normalizes style values (e.g., adds "px" units where needed).
18581
- *
18582
- * ```jsx
18583
- * const MyButton = ({ style, children }) => (
18584
- * <button style={withPropsStyle({ padding: 10 }, style)}>
18585
- * {children}
18586
- * </button>
18587
- * );
18581
+ * Layout Style Hook
18588
18582
  *
18589
- * // Usage:
18590
- * <MyButton style={{ color: 'red', fontSize: 14 }} />
18591
- * <MyButton style="color: blue; margin: 5px;" />
18592
- * <MyButton /> // Just base styles
18593
- * ```
18583
+ * This hook processes layout-related props and converts them into CSS styles.
18584
+ * It handles spacing (margin/padding), alignment (alignX/alignY), and expansion behavior.
18585
+ * The hook is context-aware and adapts behavior based on flex direction.
18594
18586
  *
18595
- * @param {string|object} baseStyle - The component's base style (string or object)
18596
- * @param {string|object} [styleFromProps] - Additional style from props (optional)
18597
- * @returns {object} The merged and normalized style object
18587
+ * Key features:
18588
+ * - Spacing: margin/padding with X/Y shortcuts and directional variants
18589
+ * - Alignment: alignX/alignY using align-self and auto margins
18590
+ * - Expansion: expand prop for taking remaining space (flexGrow or width: 100%)
18591
+ * - Context-aware: behavior changes based on FlexDirectionContext (row/column/none)
18598
18592
  */
18599
- const withPropsStyle = (baseStyle, styleFromProps) => {
18600
- return mergeStyles(baseStyle, styleFromProps, "css");
18601
- };
18602
18593
 
18603
- const consumeSpacingProps = props => {
18604
- const style = {};
18594
+
18595
+ /**
18596
+ * Converts layout props into CSS styles
18597
+ * @param {Object} props - Component props containing layout properties
18598
+ * @param {string|number} [props.margin] - All-sides margin
18599
+ * @param {string|number} [props.marginX] - Horizontal margin (left + right)
18600
+ * @param {string|number} [props.marginY] - Vertical margin (top + bottom)
18601
+ * @param {string|number} [props.marginLeft] - Left margin
18602
+ * @param {string|number} [props.marginRight] - Right margin
18603
+ * @param {string|number} [props.marginTop] - Top margin
18604
+ * @param {string|number} [props.marginBottom] - Bottom margin
18605
+ * @param {string|number} [props.padding] - All-sides padding
18606
+ * @param {string|number} [props.paddingX] - Horizontal padding (left + right)
18607
+ * @param {string|number} [props.paddingY] - Vertical padding (top + bottom)
18608
+ * @param {string|number} [props.paddingLeft] - Left padding
18609
+ * @param {string|number} [props.paddingRight] - Right padding
18610
+ * @param {string|number} [props.paddingTop] - Top padding
18611
+ * @param {string|number} [props.paddingBottom] - Bottom padding
18612
+ * @param {"start"|"center"|"end"|"stretch"} [props.alignX] - Horizontal alignment
18613
+ * @param {"start"|"center"|"end"|"stretch"} [props.alignY] - Vertical alignment
18614
+ * @param {boolean} [props.expandX] - Whether element should expand horizontally to fill available space
18615
+ * @param {boolean} [props.expandY] - Whether element should expand vertically to fill available space
18616
+ * @returns {Object} Object with categorized styles: { margin, padding, alignment, expansion, all }
18617
+ */
18618
+ const useLayoutStyle = (props) => {
18619
+ const flexDirection = useContext(FlexDirectionContext);
18620
+
18621
+ const marginStyle = {};
18622
+ const paddingStyle = {};
18623
+ const alignmentStyle = {};
18624
+ const expansionStyle = {};
18625
+
18605
18626
  {
18606
- const margin = props.margin;
18607
- const marginX = props.marginX;
18608
- const marginY = props.marginY;
18609
- const marginLeft = props.marginLeft;
18610
- const marginRight = props.marginRight;
18611
- const marginTop = props.marginTop;
18612
- const marginBottom = props.marginBottom;
18613
- delete props.margin;
18614
- delete props.marginX;
18615
- delete props.marginY;
18616
- delete props.marginLeft;
18617
- delete props.marginRight;
18618
- delete props.marginTop;
18619
- delete props.marginBottom;
18620
- if (margin !== undefined) {
18621
- style.margin = margin;
18622
- }
18623
- if (marginLeft !== undefined) {
18624
- style.marginLeft = marginLeft;
18625
- } else if (marginX !== undefined) {
18626
- style.marginLeft = marginX;
18627
- }
18628
- if (marginRight !== undefined) {
18629
- style.marginRight = marginRight;
18630
- } else if (marginX !== undefined) {
18631
- style.marginRight = marginX;
18632
- }
18633
- if (marginTop !== undefined) {
18634
- style.marginTop = marginTop;
18635
- } else if (marginY !== undefined) {
18636
- style.marginTop = marginY;
18637
- }
18638
- if (marginBottom !== undefined) {
18639
- style.marginBottom = marginBottom;
18640
- } else if (marginY !== undefined) {
18641
- style.marginBottom = marginY;
18627
+ {
18628
+ const margin = props.margin;
18629
+ const marginX = props.marginX;
18630
+ const marginY = props.marginY;
18631
+ const marginLeft = props.marginLeft;
18632
+ const marginRight = props.marginRight;
18633
+ const marginTop = props.marginTop;
18634
+ const marginBottom = props.marginBottom;
18635
+ delete props.margin;
18636
+ delete props.marginX;
18637
+ delete props.marginY;
18638
+ delete props.marginLeft;
18639
+ delete props.marginRight;
18640
+ delete props.marginTop;
18641
+ delete props.marginBottom;
18642
+
18643
+ if (margin !== undefined) {
18644
+ marginStyle.margin = margin;
18645
+ }
18646
+ if (marginLeft !== undefined) {
18647
+ marginStyle.marginLeft = marginLeft;
18648
+ } else if (marginX !== undefined) {
18649
+ marginStyle.marginLeft = marginX;
18650
+ }
18651
+ if (marginRight !== undefined) {
18652
+ marginStyle.marginRight = marginRight;
18653
+ } else if (marginX !== undefined) {
18654
+ marginStyle.marginRight = marginX;
18655
+ }
18656
+ if (marginTop !== undefined) {
18657
+ marginStyle.marginTop = marginTop;
18658
+ } else if (marginY !== undefined) {
18659
+ marginStyle.marginTop = marginY;
18660
+ }
18661
+ if (marginBottom !== undefined) {
18662
+ marginStyle.marginBottom = marginBottom;
18663
+ } else if (marginY !== undefined) {
18664
+ marginStyle.marginBottom = marginY;
18665
+ }
18666
+ }
18667
+ {
18668
+ const padding = props.padding;
18669
+ const paddingX = props.paddingX;
18670
+ const paddingY = props.paddingY;
18671
+ const paddingLeft = props.paddingLeft;
18672
+ const paddingRight = props.paddingRight;
18673
+ const paddingTop = props.paddingTop;
18674
+ const paddingBottom = props.paddingBottom;
18675
+ delete props.padding;
18676
+ delete props.paddingX;
18677
+ delete props.paddingY;
18678
+ delete props.paddingLeft;
18679
+ delete props.paddingRight;
18680
+ delete props.paddingTop;
18681
+ delete props.paddingBottom;
18682
+
18683
+ if (padding !== undefined) {
18684
+ paddingStyle.padding = padding;
18685
+ }
18686
+ if (paddingLeft !== undefined) {
18687
+ paddingStyle.paddingLeft = paddingLeft;
18688
+ } else if (paddingX !== undefined) {
18689
+ paddingStyle.paddingLeft = paddingX;
18690
+ }
18691
+ if (paddingRight !== undefined) {
18692
+ paddingStyle.paddingRight = paddingRight;
18693
+ } else if (paddingX !== undefined) {
18694
+ paddingStyle.paddingRight = paddingX;
18695
+ }
18696
+ if (paddingTop !== undefined) {
18697
+ paddingStyle.paddingTop = paddingTop;
18698
+ } else if (paddingY !== undefined) {
18699
+ paddingStyle.paddingTop = paddingY;
18700
+ }
18701
+ if (paddingBottom !== undefined) {
18702
+ paddingStyle.paddingBottom = paddingBottom;
18703
+ } else if (paddingY !== undefined) {
18704
+ paddingStyle.paddingBottom = paddingY;
18705
+ }
18706
+ }
18707
+ }
18708
+
18709
+ {
18710
+ const alignX = props.alignX;
18711
+ const alignY = props.alignY;
18712
+ delete props.alignX;
18713
+ delete props.alignY;
18714
+
18715
+ // flex
18716
+ if (flexDirection === "row") {
18717
+ // In row direction: alignX controls justify-content, alignY controls align-self
18718
+ if (alignY !== undefined && alignY !== "start") {
18719
+ alignmentStyle.alignSelf = alignY;
18720
+ }
18721
+ // For row, alignX uses auto margins for positioning
18722
+ // NOTE: Auto margins only work effectively for positioning individual items.
18723
+ // When multiple adjacent items have the same auto margin alignment (e.g., alignX="end"),
18724
+ // only the first item will be positioned as expected because subsequent items
18725
+ // will be positioned relative to the previous item's margins, not the container edge.
18726
+ if (alignX !== undefined) {
18727
+ if (alignX === "start") {
18728
+ alignmentStyle.marginRight = "auto";
18729
+ } else if (alignX === "end") {
18730
+ alignmentStyle.marginLeft = "auto";
18731
+ } else if (alignX === "center") {
18732
+ alignmentStyle.marginLeft = "auto";
18733
+ alignmentStyle.marginRight = "auto";
18734
+ }
18735
+ }
18736
+ } else if (flexDirection === "column") {
18737
+ // In column direction: alignX controls align-self, alignY uses auto margins
18738
+ if (alignX !== undefined && alignX !== "start") {
18739
+ alignmentStyle.alignSelf = alignX;
18740
+ }
18741
+ // For column, alignY uses auto margins for positioning
18742
+ // NOTE: Same auto margin limitation applies - multiple adjacent items with
18743
+ // the same alignY won't all position relative to container edges.
18744
+ if (alignY !== undefined) {
18745
+ if (alignY === "start") {
18746
+ alignmentStyle.marginBottom = "auto";
18747
+ } else if (alignY === "end") {
18748
+ alignmentStyle.marginTop = "auto";
18749
+ } else if (alignY === "center") {
18750
+ alignmentStyle.marginTop = "auto";
18751
+ alignmentStyle.marginBottom = "auto";
18752
+ }
18753
+ }
18754
+ }
18755
+ // non flex
18756
+ else {
18757
+ if (alignX === "start") {
18758
+ alignmentStyle.marginRight = "auto";
18759
+ } else if (alignX === "center") {
18760
+ alignmentStyle.marginLeft = "auto";
18761
+ alignmentStyle.marginRight = "auto";
18762
+ } else if (alignX === "end") {
18763
+ alignmentStyle.marginLeft = "auto";
18764
+ }
18765
+
18766
+ if (alignY === "start") {
18767
+ alignmentStyle.marginBottom = "auto";
18768
+ } else if (alignY === "center") {
18769
+ alignmentStyle.marginTop = "auto";
18770
+ alignmentStyle.marginBottom = "auto";
18771
+ } else if (alignY === "end") {
18772
+ alignmentStyle.marginTop = "auto";
18773
+ }
18642
18774
  }
18643
18775
  }
18776
+
18644
18777
  {
18645
- const padding = props.padding;
18646
- const paddingX = props.paddingX;
18647
- const paddingY = props.paddingY;
18648
- const paddingLeft = props.paddingLeft;
18649
- const paddingRight = props.paddingRight;
18650
- const paddingTop = props.paddingTop;
18651
- const paddingBottom = props.paddingBottom;
18652
- delete props.padding;
18653
- delete props.paddingX;
18654
- delete props.paddingY;
18655
- delete props.paddingLeft;
18656
- delete props.paddingRight;
18657
- delete props.paddingTop;
18658
- delete props.paddingBottom;
18659
- if (padding !== undefined) {
18660
- style.padding = padding;
18661
- }
18662
- if (paddingLeft !== undefined) {
18663
- style.paddingLeft = paddingLeft;
18664
- } else if (paddingX !== undefined) {
18665
- style.paddingLeft = paddingX;
18666
- }
18667
- if (paddingRight !== undefined) {
18668
- style.paddingRight = paddingRight;
18669
- } else if (paddingX !== undefined) {
18670
- style.paddingRight = paddingX;
18671
- }
18672
- if (paddingTop !== undefined) {
18673
- style.paddingTop = paddingTop;
18674
- } else if (paddingY !== undefined) {
18675
- style.paddingTop = paddingY;
18676
- }
18677
- if (paddingBottom !== undefined) {
18678
- style.paddingBottom = paddingBottom;
18679
- } else if (paddingY !== undefined) {
18680
- style.paddingBottom = paddingY;
18778
+ const expand = props.expand;
18779
+ delete props.expand;
18780
+
18781
+ {
18782
+ const expandX = props.expandX || expand;
18783
+ delete props.expandX;
18784
+ if (expandX) {
18785
+ if (flexDirection === "row") {
18786
+ expansionStyle.flexGrow = 1; // Grow horizontally in row
18787
+ } else if (flexDirection === "column") {
18788
+ expansionStyle.width = "100%"; // Take full width in column
18789
+ } else {
18790
+ expansionStyle.width = "100%"; // Take full width outside flex
18791
+ }
18792
+ }
18793
+ }
18794
+
18795
+ {
18796
+ const expandY = props.expandY || expand;
18797
+ delete props.expandY;
18798
+ if (expandY) {
18799
+ if (flexDirection === "row") {
18800
+ expansionStyle.height = "100%"; // Take full height in row
18801
+ } else if (flexDirection === "column") {
18802
+ expansionStyle.flexGrow = 1; // Grow vertically in column
18803
+ } else {
18804
+ expansionStyle.height = "100%"; // Take full height outside flex
18805
+ }
18806
+ }
18681
18807
  }
18682
18808
  }
18683
- return style;
18684
- };
18685
- const Spacing = ({
18686
- style,
18687
- children,
18688
- ...rest
18689
- }) => {
18690
- const styleForSpacing = consumeSpacingProps(rest);
18691
- return jsx("div", {
18692
- ...rest,
18693
- style: withPropsStyle(styleForSpacing, style),
18694
- children: children
18695
- });
18809
+
18810
+ // Merge all styles for convenience
18811
+ const allStyles = {
18812
+ ...marginStyle,
18813
+ ...paddingStyle,
18814
+ ...alignmentStyle,
18815
+ ...expansionStyle,
18816
+ };
18817
+
18818
+ return {
18819
+ margin: marginStyle,
18820
+ padding: paddingStyle,
18821
+ alignment: alignmentStyle,
18822
+ expansion: expansionStyle,
18823
+ all: allStyles,
18824
+ };
18696
18825
  };
18697
18826
 
18698
18827
  const useNetworkSpeed = () => {
@@ -19269,6 +19398,31 @@ const LoaderBackgroundBasic = ({
19269
19398
  });
19270
19399
  };
19271
19400
 
19401
+ /**
19402
+ * Merges a component's base style with style received from props.
19403
+ * Automatically normalizes style values (e.g., adds "px" units where needed).
19404
+ *
19405
+ * ```jsx
19406
+ * const MyButton = ({ style, children }) => (
19407
+ * <button style={withPropsStyle({ padding: 10 }, style)}>
19408
+ * {children}
19409
+ * </button>
19410
+ * );
19411
+ *
19412
+ * // Usage:
19413
+ * <MyButton style={{ color: 'red', fontSize: 14 }} />
19414
+ * <MyButton style="color: blue; margin: 5px;" />
19415
+ * <MyButton /> // Just base styles
19416
+ * ```
19417
+ *
19418
+ * @param {string|object} baseStyle - The component's base style (string or object)
19419
+ * @param {string|object} [styleFromProps] - Additional style from props (optional)
19420
+ * @returns {object} The merged and normalized style object
19421
+ */
19422
+ const withPropsStyle = (baseStyle, styleFromProps) => {
19423
+ return mergeStyles(baseStyle, styleFromProps, "css");
19424
+ };
19425
+
19272
19426
  // autoFocus does not work so we focus in a useLayoutEffect,
19273
19427
  // see https://github.com/preactjs/preact/issues/1255
19274
19428
 
@@ -20246,11 +20400,14 @@ const NaviCheckbox = ({
20246
20400
  useLayoutEffect(() => {
20247
20401
  return initCustomField(ref.current, inputRef.current);
20248
20402
  }, []);
20403
+ const {
20404
+ all
20405
+ } = useLayoutStyle(rest);
20249
20406
  const innerStyle = withPropsStyle({
20407
+ ...all,
20250
20408
  ...(accentColor ? {
20251
20409
  "--accent-color": accentColor
20252
- } : {}),
20253
- ...consumeSpacingProps(rest)
20410
+ } : {})
20254
20411
  }, style);
20255
20412
  return jsxs("div", {
20256
20413
  ...rest,
@@ -20671,11 +20828,14 @@ const NaviRadio = ({
20671
20828
  useLayoutEffect(() => {
20672
20829
  return initCustomField(ref.current, inputRef.current);
20673
20830
  }, []);
20831
+ const {
20832
+ all
20833
+ } = useLayoutStyle(rest);
20674
20834
  const innerStyle = withPropsStyle({
20835
+ ...all,
20675
20836
  ...(accentColor ? {
20676
20837
  "--accent-color": accentColor
20677
- } : {}),
20678
- ...consumeSpacingProps(rest)
20838
+ } : {})
20679
20839
  }, style);
20680
20840
  return jsxs("span", {
20681
20841
  ...rest,
@@ -20795,6 +20955,8 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
20795
20955
  --color: currentColor;
20796
20956
  --color-readonly: color-mix(in srgb, currentColor 60%, transparent);
20797
20957
  --color-disabled: var(--color-readonly);
20958
+
20959
+ width: 100%;
20798
20960
  color: var(--color);
20799
20961
 
20800
20962
  background-color: var(--background-color);
@@ -20873,8 +21035,6 @@ const InputTextualBasic = forwardRef((props, ref) => {
20873
21035
  // visual
20874
21036
  appearance = "navi",
20875
21037
  accentColor,
20876
- width,
20877
- height,
20878
21038
  className,
20879
21039
  style,
20880
21040
  ...rest
@@ -20893,11 +21053,13 @@ const InputTextualBasic = forwardRef((props, ref) => {
20893
21053
  });
20894
21054
  useConstraints(innerRef, constraints);
20895
21055
  const innerClassName = withPropsClassName(appearance === "navi" ? "navi_input" : undefined, className);
20896
- const innerStyle = withPropsStyle({
20897
- width,
20898
- height,
20899
- ...consumeSpacingProps(rest)
20900
- }, style);
21056
+ const {
21057
+ margin,
21058
+ padding,
21059
+ alignment,
21060
+ expansion
21061
+ } = useLayoutStyle(rest);
21062
+ const innerStyle = withPropsStyle(padding, style);
20901
21063
  const inputTextual = jsx("input", {
20902
21064
  ...rest,
20903
21065
  ref: innerRef,
@@ -20942,11 +21104,12 @@ const InputTextualBasic = forwardRef((props, ref) => {
20942
21104
  return jsx(LoadableInlineElement, {
20943
21105
  loading: innerLoading,
20944
21106
  style: {
21107
+ ...margin,
21108
+ ...alignment,
21109
+ ...expansion,
20945
21110
  "--accent-color": accentColor || "light-dark(#355fcc, #4476ff)"
20946
21111
  },
20947
21112
  color: "var(--accent-color)",
20948
- width: width,
20949
- height: height,
20950
21113
  inset: -1,
20951
21114
  children: inputTextual
20952
21115
  });
@@ -21369,157 +21532,6 @@ const Editable = forwardRef((props, ref) => {
21369
21532
  });
21370
21533
  });
21371
21534
 
21372
- installImportMetaCss(import.meta);import.meta.css = /* css */`
21373
- .navi_flex_row {
21374
- display: flex;
21375
- flex-direction: row;
21376
- gap: 0;
21377
- }
21378
-
21379
- .navi_flex_column {
21380
- display: flex;
21381
- flex-direction: column;
21382
- gap: 0;
21383
- }
21384
-
21385
- .navi_flex_item {
21386
- flex-shrink: 0;
21387
- }
21388
- `;
21389
- const FlexDirectionContext = createContext();
21390
- const FlexRow = ({
21391
- alignX,
21392
- alignY,
21393
- gap,
21394
- style,
21395
- children,
21396
- ...rest
21397
- }) => {
21398
- const innerStyle = withPropsStyle({
21399
- // Only set justifyContent if it's not the default "start"
21400
- justifyContent: alignX !== "start" ? alignX : undefined,
21401
- // Only set alignItems if it's not the default "stretch"
21402
- alignItems: alignY !== "stretch" ? alignY : undefined,
21403
- gap,
21404
- ...consumeSpacingProps(rest)
21405
- }, style);
21406
- return jsx("div", {
21407
- ...rest,
21408
- className: "navi_flex_row",
21409
- style: innerStyle,
21410
- children: jsx(FlexDirectionContext.Provider, {
21411
- value: "row",
21412
- children: children
21413
- })
21414
- });
21415
- };
21416
- const FlexColumn = ({
21417
- alignX,
21418
- alignY,
21419
- gap,
21420
- style,
21421
- children,
21422
- ...rest
21423
- }) => {
21424
- const innerStyle = withPropsStyle({
21425
- // Only set alignItems if it's not the default "stretch"
21426
- alignItems: alignX !== "stretch" ? alignX : undefined,
21427
- // Only set justifyContent if it's not the default "start"
21428
- justifyContent: alignY !== "start" ? alignY : undefined,
21429
- gap,
21430
- ...consumeSpacingProps(rest)
21431
- }, style);
21432
- return jsx("div", {
21433
- ...rest,
21434
- className: "navi_flex_column",
21435
- style: innerStyle,
21436
- children: jsx(FlexDirectionContext.Provider, {
21437
- value: "column",
21438
- children: children
21439
- })
21440
- });
21441
- };
21442
- const useConsumAlignProps = props => {
21443
- const flexDirection = useContext(FlexDirectionContext);
21444
- const alignX = props.alignX;
21445
- const alignY = props.alignY;
21446
- delete props.alignX;
21447
- delete props.alignY;
21448
- const style = {};
21449
- if (flexDirection === "row") {
21450
- // In row direction: alignX controls justify-content, alignY controls align-self
21451
- if (alignY !== undefined && alignY !== "start") {
21452
- style.alignSelf = alignY;
21453
- }
21454
- // For row, alignX uses auto margins for positioning
21455
- // NOTE: Auto margins only work effectively for positioning individual items.
21456
- // When multiple adjacent items have the same auto margin alignment (e.g., alignX="end"),
21457
- // only the first item will be positioned as expected because subsequent items
21458
- // will be positioned relative to the previous item's margins, not the container edge.
21459
- if (alignX !== undefined) {
21460
- if (alignX === "start") {
21461
- style.marginRight = "auto";
21462
- } else if (alignX === "end") {
21463
- style.marginLeft = "auto";
21464
- } else if (alignX === "center") {
21465
- style.marginLeft = "auto";
21466
- style.marginRight = "auto";
21467
- }
21468
- }
21469
- } else if (flexDirection === "column") {
21470
- // In column direction: alignX controls align-self, alignY uses auto margins
21471
- if (alignX !== undefined && alignX !== "start") {
21472
- style.alignSelf = alignX;
21473
- }
21474
- // For column, alignY uses auto margins for positioning
21475
- // NOTE: Same auto margin limitation applies - multiple adjacent items with
21476
- // the same alignY won't all position relative to container edges.
21477
- if (alignY !== undefined) {
21478
- if (alignY === "start") {
21479
- style.marginBottom = "auto";
21480
- } else if (alignY === "end") {
21481
- style.marginTop = "auto";
21482
- } else if (alignY === "center") {
21483
- style.marginTop = "auto";
21484
- style.marginBottom = "auto";
21485
- }
21486
- }
21487
- }
21488
- return style;
21489
- };
21490
- const FlexItem = ({
21491
- alignX,
21492
- alignY,
21493
- grow,
21494
- shrink,
21495
- className,
21496
- style,
21497
- children,
21498
- ...rest
21499
- }) => {
21500
- const flexDirection = useContext(FlexDirectionContext);
21501
- if (!flexDirection) {
21502
- console.warn("FlexItem must be used within a FlexRow or FlexColumn component.");
21503
- }
21504
- const innerClassName = withPropsClassName("navi_flex_item", className);
21505
- const alignStyle = useConsumAlignProps({
21506
- alignX,
21507
- alignY
21508
- });
21509
- const innerStyle = withPropsStyle({
21510
- flexGrow: grow ? 1 : undefined,
21511
- flexShrink: shrink ? 1 : undefined,
21512
- ...consumeSpacingProps(rest),
21513
- ...alignStyle
21514
- }, style);
21515
- return jsx("div", {
21516
- ...rest,
21517
- className: innerClassName,
21518
- style: innerStyle,
21519
- children: children
21520
- });
21521
- };
21522
-
21523
21535
  const useFormEvents = (
21524
21536
  elementRef,
21525
21537
  {
@@ -21620,6 +21632,7 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
21620
21632
  .navi_button_content {
21621
21633
  position: relative;
21622
21634
  display: inline-flex;
21635
+ width: 100%;
21623
21636
  padding-top: var(--padding-y);
21624
21637
  padding-right: var(--padding-x);
21625
21638
  padding-bottom: var(--padding-y);
@@ -21741,8 +21754,6 @@ const ButtonBasic = forwardRef((props, ref) => {
21741
21754
  autoFocus,
21742
21755
  // visual
21743
21756
  appearance = "navi",
21744
- alignX,
21745
- alignY,
21746
21757
  discrete,
21747
21758
  className,
21748
21759
  style,
@@ -21766,13 +21777,10 @@ const ButtonBasic = forwardRef((props, ref) => {
21766
21777
  buttonChildren = children;
21767
21778
  }
21768
21779
  const innerClassName = withPropsClassName(appearance === "navi" ? "navi_button" : undefined, className);
21769
- const innerStyle = withPropsStyle({
21770
- ...consumeSpacingProps(rest),
21771
- ...useConsumAlignProps({
21772
- alignX,
21773
- alignY
21774
- })
21775
- }, style);
21780
+ const {
21781
+ all
21782
+ } = useLayoutStyle(rest);
21783
+ const innerStyle = withPropsStyle(all, style);
21776
21784
  return jsx("button", {
21777
21785
  ...rest,
21778
21786
  ref: innerRef,
@@ -24347,7 +24355,6 @@ const LinkBasic = forwardRef((props, ref) => {
24347
24355
  });
24348
24356
  const LinkPlain = forwardRef((props, ref) => {
24349
24357
  const {
24350
- className = "",
24351
24358
  loading,
24352
24359
  readOnly,
24353
24360
  disabled,
@@ -24360,6 +24367,9 @@ const LinkPlain = forwardRef((props, ref) => {
24360
24367
  onClick,
24361
24368
  onKeyDown,
24362
24369
  href,
24370
+ // visual
24371
+ className,
24372
+ style,
24363
24373
  ...rest
24364
24374
  } = props;
24365
24375
  const innerRef = useRef();
@@ -24369,6 +24379,11 @@ const LinkPlain = forwardRef((props, ref) => {
24369
24379
  useConstraints(innerRef, constraints);
24370
24380
  const shouldDimColor = readOnly || disabled;
24371
24381
  useDimColorWhen(innerRef, shouldDimColor);
24382
+ const innerClassName = withPropsClassName("navi_link", className);
24383
+ const {
24384
+ all
24385
+ } = useLayoutStyle(rest);
24386
+ const innerStyle = withPropsStyle(all, style);
24372
24387
  return jsx(LoadableInlineElement, {
24373
24388
  loading: loading,
24374
24389
  color: "light-dark(#355fcc, #3b82f6)",
@@ -24376,7 +24391,8 @@ const LinkPlain = forwardRef((props, ref) => {
24376
24391
  ...rest,
24377
24392
  ref: innerRef,
24378
24393
  href: href,
24379
- className: ["navi_link", ...className.split(" ")].join(" "),
24394
+ className: innerClassName,
24395
+ style: innerStyle,
24380
24396
  "aria-busy": loading,
24381
24397
  inert: disabled,
24382
24398
  "data-field": "",
@@ -28220,23 +28236,17 @@ const Text = ({
28220
28236
  italic,
28221
28237
  underline,
28222
28238
  style,
28223
- alignX,
28224
28239
  ...rest
28225
28240
  }) => {
28241
+ const {
28242
+ all
28243
+ } = useLayoutStyle(rest);
28226
28244
  const innerStyle = withPropsStyle({
28245
+ ...all,
28227
28246
  color,
28228
28247
  fontWeight: bold ? "bold" : undefined,
28229
28248
  fontStyle: italic ? "italic" : undefined,
28230
- textDecoration: underline ? "underline" : undefined,
28231
- ...consumeSpacingProps(rest),
28232
- ...(alignX === "start" ? {} : alignX === "center" ? {
28233
- alignSelf: "center",
28234
- marginLeft: "auto",
28235
- marginRight: "auto"
28236
- } : {
28237
- alignSelf: "end",
28238
- marginLeft: "auto"
28239
- })
28249
+ textDecoration: underline ? "underline" : undefined
28240
28250
  }, style);
28241
28251
  return jsx("span", {
28242
28252
  ...rest,
@@ -28302,6 +28312,129 @@ const TextAndCount = ({
28302
28312
  });
28303
28313
  };
28304
28314
 
28315
+ installImportMetaCss(import.meta);import.meta.css = /* css */`
28316
+ .navi_flex_row {
28317
+ display: flex;
28318
+ flex-direction: row;
28319
+ gap: 0;
28320
+ }
28321
+
28322
+ .navi_flex_column {
28323
+ display: flex;
28324
+ flex-direction: column;
28325
+ gap: 0;
28326
+ }
28327
+
28328
+ .navi_flex_item {
28329
+ flex-shrink: 0;
28330
+ }
28331
+ `;
28332
+ const FlexRow = ({
28333
+ alignX,
28334
+ alignY,
28335
+ gap,
28336
+ style,
28337
+ children,
28338
+ ...rest
28339
+ }) => {
28340
+ const {
28341
+ all
28342
+ } = useLayoutStyle(rest);
28343
+ const innerStyle = withPropsStyle({
28344
+ ...all,
28345
+ // Only set justifyContent if it's not the default "start"
28346
+ justifyContent: alignX !== "start" ? alignX : undefined,
28347
+ // Only set alignItems if it's not the default "stretch"
28348
+ alignItems: alignY !== "stretch" ? alignY : undefined,
28349
+ gap
28350
+ }, style);
28351
+ return jsx("div", {
28352
+ ...rest,
28353
+ className: "navi_flex_row",
28354
+ style: innerStyle,
28355
+ children: jsx(FlexDirectionContext.Provider, {
28356
+ value: "row",
28357
+ children: children
28358
+ })
28359
+ });
28360
+ };
28361
+ const FlexColumn = ({
28362
+ alignX,
28363
+ alignY,
28364
+ gap,
28365
+ style,
28366
+ children,
28367
+ ...rest
28368
+ }) => {
28369
+ const {
28370
+ all
28371
+ } = useLayoutStyle(rest);
28372
+ const innerStyle = withPropsStyle({
28373
+ ...all,
28374
+ // Only set alignItems if it's not the default "stretch"
28375
+ alignItems: alignX !== "stretch" ? alignX : undefined,
28376
+ // Only set justifyContent if it's not the default "start"
28377
+ justifyContent: alignY !== "start" ? alignY : undefined,
28378
+ gap
28379
+ }, style);
28380
+ return jsx("div", {
28381
+ ...rest,
28382
+ className: "navi_flex_column",
28383
+ style: innerStyle,
28384
+ children: jsx(FlexDirectionContext.Provider, {
28385
+ value: "column",
28386
+ children: children
28387
+ })
28388
+ });
28389
+ };
28390
+ const FlexItem = ({
28391
+ shrink,
28392
+ className,
28393
+ expand,
28394
+ style,
28395
+ children,
28396
+ ...rest
28397
+ }) => {
28398
+ const flexDirection = useContext(FlexDirectionContext);
28399
+ if (!flexDirection) {
28400
+ console.warn("FlexItem must be used within a FlexRow or FlexColumn component.");
28401
+ }
28402
+ const innerClassName = withPropsClassName("navi_flex_item", className);
28403
+ const {
28404
+ all
28405
+ } = useLayoutStyle(rest);
28406
+ const innerStyle = withPropsStyle({
28407
+ ...all,
28408
+ flexGrow: expand ? 1 : undefined,
28409
+ flexShrink: shrink ? 1 : undefined
28410
+ }, style);
28411
+ return jsx("div", {
28412
+ ...rest,
28413
+ className: innerClassName,
28414
+ style: innerStyle,
28415
+ children: children
28416
+ });
28417
+ };
28418
+
28419
+ const Spacing = ({
28420
+ style,
28421
+ children,
28422
+ ...rest
28423
+ }) => {
28424
+ const {
28425
+ padding,
28426
+ margin
28427
+ } = useLayoutStyle(rest);
28428
+ return jsx("div", {
28429
+ ...rest,
28430
+ style: withPropsStyle({
28431
+ ...margin,
28432
+ ...padding
28433
+ }, style),
28434
+ children: children
28435
+ });
28436
+ };
28437
+
28305
28438
  const createUniqueValueConstraint = (
28306
28439
  // the set might be incomplete (the front usually don't have the full copy of all the items from the backend)
28307
28440
  // but this is already nice to help user with what we know