@jsenv/navi 0.23.3 → 0.23.4
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/jsenv_navi.js +59 -5
- package/dist/jsenv_navi.js.map +20 -12
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -21447,7 +21447,8 @@ const useUIState = (uiStateController) => {
|
|
|
21447
21447
|
return trackedUIState;
|
|
21448
21448
|
};
|
|
21449
21449
|
|
|
21450
|
-
installImportMetaCssBuild(import.meta)
|
|
21450
|
+
installImportMetaCssBuild(import.meta);/* eslint-disable jsenv/no-unknown-params */
|
|
21451
|
+
const css$r = /* css */`
|
|
21451
21452
|
@layer navi {
|
|
21452
21453
|
.navi_button {
|
|
21453
21454
|
--button-outline-width: 1px;
|
|
@@ -21508,6 +21509,11 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
|
|
|
21508
21509
|
}
|
|
21509
21510
|
}
|
|
21510
21511
|
|
|
21512
|
+
a.navi_button {
|
|
21513
|
+
color: inherit;
|
|
21514
|
+
text-decoration: none;
|
|
21515
|
+
}
|
|
21516
|
+
|
|
21511
21517
|
.navi_button {
|
|
21512
21518
|
/* Internal vars — prefixed with --x- to signal they are private, do not use from outside */
|
|
21513
21519
|
--x-button-outline-width: var(--button-outline-width);
|
|
@@ -21706,11 +21712,40 @@ installImportMetaCssBuild(import.meta);const css$r = /* css */`
|
|
|
21706
21712
|
const Button = props => {
|
|
21707
21713
|
import.meta.css = [css$r, "@jsenv/navi/src/field/button.jsx"];
|
|
21708
21714
|
return renderActionableComponent(props, {
|
|
21709
|
-
Basic:
|
|
21715
|
+
Basic: ButtonBasicDispatch,
|
|
21710
21716
|
WithAction: ButtonWithAction,
|
|
21711
21717
|
WithActionInsideForm: ButtonWithActionInsideForm
|
|
21712
21718
|
});
|
|
21713
21719
|
};
|
|
21720
|
+
const ButtonBasicDispatch = props => {
|
|
21721
|
+
if (props.route) {
|
|
21722
|
+
return jsx(ButtonWithRoute, {
|
|
21723
|
+
...props
|
|
21724
|
+
});
|
|
21725
|
+
}
|
|
21726
|
+
return jsx(ButtonBasic, {
|
|
21727
|
+
...props
|
|
21728
|
+
});
|
|
21729
|
+
};
|
|
21730
|
+
const ButtonWithRoute = ({
|
|
21731
|
+
route,
|
|
21732
|
+
routeParams,
|
|
21733
|
+
children,
|
|
21734
|
+
...rest
|
|
21735
|
+
}) => {
|
|
21736
|
+
const url = route.buildUrl(routeParams);
|
|
21737
|
+
const {
|
|
21738
|
+
matching
|
|
21739
|
+
} = useRouteStatus(route);
|
|
21740
|
+
const paramsAreMatching = route.matchesParams(routeParams);
|
|
21741
|
+
const linkMatching = matching && paramsAreMatching;
|
|
21742
|
+
return jsx(ButtonBasic, {
|
|
21743
|
+
href: url,
|
|
21744
|
+
"data-href-current": linkMatching ? "" : undefined,
|
|
21745
|
+
...rest,
|
|
21746
|
+
children: children || route.buildRelativeUrl(routeParams)
|
|
21747
|
+
});
|
|
21748
|
+
};
|
|
21714
21749
|
const ButtonStyleCSSVars = {
|
|
21715
21750
|
"outlineWidth": "--button-outline-width",
|
|
21716
21751
|
"borderWidth": "--button-border-width",
|
|
@@ -21758,6 +21793,10 @@ const ButtonBasic = props => {
|
|
|
21758
21793
|
disabled,
|
|
21759
21794
|
loading,
|
|
21760
21795
|
autoFocus,
|
|
21796
|
+
// href/link
|
|
21797
|
+
href,
|
|
21798
|
+
target,
|
|
21799
|
+
rel,
|
|
21761
21800
|
// visual
|
|
21762
21801
|
icon,
|
|
21763
21802
|
revealOnInteraction = icon,
|
|
@@ -21773,6 +21812,18 @@ const ButtonBasic = props => {
|
|
|
21773
21812
|
const innerLoading = loading || contextLoading && contextLoadingElement === ref.current;
|
|
21774
21813
|
const innerReadOnly = readOnly || contextReadOnly || innerLoading;
|
|
21775
21814
|
const innerDisabled = disabled || contextDisabled;
|
|
21815
|
+
const isLink = href !== undefined;
|
|
21816
|
+
let as = "button";
|
|
21817
|
+
let innerTarget;
|
|
21818
|
+
let innerRel;
|
|
21819
|
+
if (isLink) {
|
|
21820
|
+
as = "a";
|
|
21821
|
+
const {
|
|
21822
|
+
isSameSite
|
|
21823
|
+
} = getHrefTargetInfo(href);
|
|
21824
|
+
innerTarget = target === undefined ? isSameSite ? undefined : "_blank" : target;
|
|
21825
|
+
innerRel = rel === undefined ? isSameSite ? undefined : "noopener noreferrer" : rel;
|
|
21826
|
+
}
|
|
21776
21827
|
const renderButtonContent = buttonProps => {
|
|
21777
21828
|
return jsxs(Text, {
|
|
21778
21829
|
...buttonProps,
|
|
@@ -21785,7 +21836,10 @@ const ButtonBasic = props => {
|
|
|
21785
21836
|
return jsxs(Box, {
|
|
21786
21837
|
"data-readonly-silent": innerLoading ? "" : undefined,
|
|
21787
21838
|
...remainingProps,
|
|
21788
|
-
as:
|
|
21839
|
+
as: as,
|
|
21840
|
+
href: href,
|
|
21841
|
+
target: innerTarget,
|
|
21842
|
+
rel: innerRel,
|
|
21789
21843
|
ref: ref,
|
|
21790
21844
|
onContextMenu: e => {
|
|
21791
21845
|
if (e.pointerType === "touch") {
|
|
@@ -21859,7 +21913,7 @@ const ButtonWithAction = props => {
|
|
|
21859
21913
|
onError: onActionError,
|
|
21860
21914
|
onEnd: onActionEnd
|
|
21861
21915
|
});
|
|
21862
|
-
return jsx(
|
|
21916
|
+
return jsx(ButtonBasicDispatch
|
|
21863
21917
|
// put data-action first to help find it in devtools
|
|
21864
21918
|
, {
|
|
21865
21919
|
"data-action": boundAction.name,
|
|
@@ -21918,7 +21972,7 @@ const ButtonWithActionInsideForm = props => {
|
|
|
21918
21972
|
}
|
|
21919
21973
|
}
|
|
21920
21974
|
});
|
|
21921
|
-
return jsx(
|
|
21975
|
+
return jsx(ButtonBasicDispatch, {
|
|
21922
21976
|
"data-action": actionBoundToFormParams.name,
|
|
21923
21977
|
...rest,
|
|
21924
21978
|
ref: ref,
|