@jsenv/navi 0.16.57 → 0.16.58
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 +287 -128
- package/dist/jsenv_navi.js.map +18 -13
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -6306,7 +6306,7 @@ const Box = props => {
|
|
|
6306
6306
|
// then we'll track ":hover" state changes even for basic elements like <div>
|
|
6307
6307
|
const pseudoClassesFromStyleSet = new Set();
|
|
6308
6308
|
boxPseudoNamedStyles = {};
|
|
6309
|
-
const
|
|
6309
|
+
const visitProp = (value, name, styleContext, boxStylesTarget, styleOrigin) => {
|
|
6310
6310
|
const isPseudoElement = name.startsWith("::");
|
|
6311
6311
|
const isPseudoClass = name.startsWith(":");
|
|
6312
6312
|
if (isPseudoElement || isPseudoClass) {
|
|
@@ -6324,14 +6324,14 @@ const Box = props => {
|
|
|
6324
6324
|
if (isPseudoElement) {
|
|
6325
6325
|
const pseudoElementStyles = {};
|
|
6326
6326
|
for (const key of pseudoStyleKeys) {
|
|
6327
|
-
|
|
6327
|
+
visitProp(value[key], key, pseudoStyleContext, pseudoElementStyles, "pseudo_style");
|
|
6328
6328
|
}
|
|
6329
6329
|
boxPseudoNamedStyles[name] = pseudoElementStyles;
|
|
6330
6330
|
return;
|
|
6331
6331
|
}
|
|
6332
6332
|
const pseudoClassStyles = {};
|
|
6333
6333
|
for (const key of pseudoStyleKeys) {
|
|
6334
|
-
|
|
6334
|
+
visitProp(value[key], key, pseudoStyleContext, pseudoClassStyles, "pseudo_style");
|
|
6335
6335
|
boxPseudoNamedStyles[name] = pseudoClassStyles;
|
|
6336
6336
|
}
|
|
6337
6337
|
return;
|
|
@@ -6395,23 +6395,28 @@ const Box = props => {
|
|
|
6395
6395
|
if (baseStyle) {
|
|
6396
6396
|
for (const key of baseStyle) {
|
|
6397
6397
|
const value = baseStyle[key];
|
|
6398
|
-
|
|
6398
|
+
visitProp(value, key, styleContext, boxStyles, "baseStyle");
|
|
6399
6399
|
}
|
|
6400
6400
|
}
|
|
6401
6401
|
for (const propName of remainingPropKeySet) {
|
|
6402
6402
|
const propValue = rest[propName];
|
|
6403
|
-
|
|
6403
|
+
const isDataAttribute = propName.startsWith("data-");
|
|
6404
|
+
if (isDataAttribute) {
|
|
6405
|
+
selfForwardedProps[propName] = propValue;
|
|
6406
|
+
continue;
|
|
6407
|
+
}
|
|
6408
|
+
visitProp(propValue, propName, styleContext, boxStyles, "prop");
|
|
6404
6409
|
}
|
|
6405
6410
|
if (typeof style === "string") {
|
|
6406
6411
|
const styleObject = normalizeStyles(style, "css");
|
|
6407
6412
|
for (const styleName of Object.keys(styleObject)) {
|
|
6408
6413
|
const styleValue = styleObject[styleName];
|
|
6409
|
-
|
|
6414
|
+
visitProp(styleValue, styleName, styleContext, boxStyles, "style");
|
|
6410
6415
|
}
|
|
6411
6416
|
} else if (style && typeof style === "object") {
|
|
6412
6417
|
for (const styleName of Object.keys(style)) {
|
|
6413
6418
|
const styleValue = style[styleName];
|
|
6414
|
-
|
|
6419
|
+
visitProp(styleValue, styleName, styleContext, boxStyles, "style");
|
|
6415
6420
|
}
|
|
6416
6421
|
}
|
|
6417
6422
|
const updateStyle = useCallback(state => {
|
|
@@ -16761,24 +16766,58 @@ const installCustomConstraintValidation = (
|
|
|
16761
16766
|
if (keydownEvent.key !== "Enter") {
|
|
16762
16767
|
return;
|
|
16763
16768
|
}
|
|
16764
|
-
|
|
16765
|
-
|
|
16766
|
-
keydownEvent.preventDefault();
|
|
16767
|
-
}
|
|
16768
|
-
dispatchActionRequestedCustomEvent(element, {
|
|
16769
|
-
event: keydownEvent,
|
|
16770
|
-
requester: element,
|
|
16771
|
-
});
|
|
16769
|
+
const elementWithAction = closestElementWithAction(element);
|
|
16770
|
+
if (!elementWithAction) {
|
|
16772
16771
|
return;
|
|
16773
16772
|
}
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16773
|
+
|
|
16774
|
+
const determineClosestFormSubmitTargetForEnterKeyEvent = () => {
|
|
16775
|
+
if (keydownEvent.defaultPrevented) {
|
|
16776
|
+
return null;
|
|
16777
|
+
}
|
|
16778
|
+
const keydownTarget = keydownEvent.target;
|
|
16779
|
+
const { form } = keydownTarget;
|
|
16780
|
+
if (!form) {
|
|
16781
|
+
return null;
|
|
16782
|
+
}
|
|
16783
|
+
if (keydownTarget.tagName === "BUTTON") {
|
|
16784
|
+
if (
|
|
16785
|
+
keydownTarget.type !== "submit" &&
|
|
16786
|
+
keydownTarget.type !== "image"
|
|
16787
|
+
) {
|
|
16788
|
+
return null;
|
|
16789
|
+
}
|
|
16790
|
+
return keydownTarget;
|
|
16791
|
+
}
|
|
16792
|
+
if (keydownTarget.tagName === "INPUT") {
|
|
16793
|
+
if (
|
|
16794
|
+
![
|
|
16795
|
+
"text",
|
|
16796
|
+
"email",
|
|
16797
|
+
"password",
|
|
16798
|
+
"search",
|
|
16799
|
+
"number",
|
|
16800
|
+
"url",
|
|
16801
|
+
"tel",
|
|
16802
|
+
].includes(keydownTarget.type)
|
|
16803
|
+
) {
|
|
16804
|
+
return null;
|
|
16805
|
+
}
|
|
16806
|
+
// when present, we use first button submitting the form as the requester
|
|
16807
|
+
// not the input, it aligns with browser behavior where
|
|
16808
|
+
// hitting Enter in a text input triggers the first submit button of the form, not the input itself
|
|
16809
|
+
return getFirstButtonSubmittingForm(keydownTarget) || keydownTarget;
|
|
16810
|
+
}
|
|
16811
|
+
return null;
|
|
16812
|
+
};
|
|
16813
|
+
const formSubmitTarget =
|
|
16814
|
+
determineClosestFormSubmitTargetForEnterKeyEvent();
|
|
16815
|
+
if (formSubmitTarget) {
|
|
16816
|
+
keydownEvent.preventDefault();
|
|
16777
16817
|
}
|
|
16778
|
-
|
|
16779
|
-
dispatchActionRequestedCustomEvent(form, {
|
|
16818
|
+
dispatchActionRequestedCustomEvent(elementWithAction, {
|
|
16780
16819
|
event: keydownEvent,
|
|
16781
|
-
requester:
|
|
16820
|
+
requester: formSubmitTarget || element,
|
|
16782
16821
|
});
|
|
16783
16822
|
};
|
|
16784
16823
|
element.addEventListener("keydown", onkeydown);
|
|
@@ -16795,29 +16834,44 @@ const installCustomConstraintValidation = (
|
|
|
16795
16834
|
if (element.tagName !== "BUTTON") {
|
|
16796
16835
|
return;
|
|
16797
16836
|
}
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
}
|
|
16802
|
-
dispatchActionRequestedCustomEvent(element, {
|
|
16803
|
-
event: clickEvent,
|
|
16804
|
-
requester: element,
|
|
16805
|
-
});
|
|
16806
|
-
return;
|
|
16807
|
-
}
|
|
16808
|
-
const { form } = element;
|
|
16809
|
-
if (!form) {
|
|
16837
|
+
const button = element;
|
|
16838
|
+
const elementWithAction = closestElementWithAction(button);
|
|
16839
|
+
if (!elementWithAction) {
|
|
16810
16840
|
return;
|
|
16811
16841
|
}
|
|
16812
|
-
|
|
16813
|
-
|
|
16814
|
-
|
|
16815
|
-
|
|
16842
|
+
const determineClosestFormSubmitTargetForClickEvent = () => {
|
|
16843
|
+
if (clickEvent.defaultPrevented) {
|
|
16844
|
+
return null;
|
|
16845
|
+
}
|
|
16846
|
+
const clickTarget = clickEvent.target;
|
|
16847
|
+
const { form } = clickTarget;
|
|
16848
|
+
if (!form) {
|
|
16849
|
+
return null;
|
|
16850
|
+
}
|
|
16851
|
+
const wouldSubmitFormByType =
|
|
16852
|
+
button.type === "submit" || button.type === "image";
|
|
16853
|
+
if (wouldSubmitFormByType) {
|
|
16854
|
+
return button;
|
|
16855
|
+
}
|
|
16856
|
+
if (button.type) {
|
|
16857
|
+
// "reset", "button" or any other non submit type, it won't submit the form
|
|
16858
|
+
return null;
|
|
16859
|
+
}
|
|
16860
|
+
const firstButtonSubmittingForm = getFirstButtonSubmittingForm(form);
|
|
16861
|
+
if (button !== firstButtonSubmittingForm) {
|
|
16862
|
+
// an other button is explicitly submitting the form, this one would not submit it
|
|
16863
|
+
return null;
|
|
16864
|
+
}
|
|
16865
|
+
// this is the only button inside the form without type attribute, so it defaults to type="submit"
|
|
16866
|
+
return button;
|
|
16867
|
+
};
|
|
16868
|
+
const formSubmitTarget = determineClosestFormSubmitTargetForClickEvent();
|
|
16869
|
+
if (formSubmitTarget) {
|
|
16816
16870
|
clickEvent.preventDefault();
|
|
16817
16871
|
}
|
|
16818
|
-
dispatchActionRequestedCustomEvent(
|
|
16872
|
+
dispatchActionRequestedCustomEvent(elementWithAction, {
|
|
16819
16873
|
event: clickEvent,
|
|
16820
|
-
requester:
|
|
16874
|
+
requester: formSubmitTarget || button,
|
|
16821
16875
|
});
|
|
16822
16876
|
};
|
|
16823
16877
|
element.addEventListener("click", onclick);
|
|
@@ -16833,13 +16887,14 @@ const installCustomConstraintValidation = (
|
|
|
16833
16887
|
break request_on_input_change;
|
|
16834
16888
|
}
|
|
16835
16889
|
const stop = listenInputChange(element, (e) => {
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
event: e,
|
|
16839
|
-
requester: element,
|
|
16840
|
-
});
|
|
16890
|
+
const elementWithAction = closestElementWithAction(element);
|
|
16891
|
+
if (!elementWithAction) {
|
|
16841
16892
|
return;
|
|
16842
16893
|
}
|
|
16894
|
+
dispatchActionRequestedCustomEvent(elementWithAction, {
|
|
16895
|
+
event: e,
|
|
16896
|
+
requester: element,
|
|
16897
|
+
});
|
|
16843
16898
|
});
|
|
16844
16899
|
addTeardown(() => {
|
|
16845
16900
|
stop();
|
|
@@ -16937,6 +16992,31 @@ const installCustomConstraintValidation = (
|
|
|
16937
16992
|
return validationInterface;
|
|
16938
16993
|
};
|
|
16939
16994
|
|
|
16995
|
+
// When interacting with an element we want to find the closest element
|
|
16996
|
+
// eventually handling the action
|
|
16997
|
+
// 1. <button> itself has an action
|
|
16998
|
+
// 2. <button> is inside a <form> with an action
|
|
16999
|
+
// 3. <button> is inside a wrapper <div> with an action (data-action is not necessarly on the interactive element itself, it can be on a wrapper, we want to support that)
|
|
17000
|
+
// 4. <button> is inside a <fieldset> or any element that catches the action like a <form> would
|
|
17001
|
+
// In examples above <button> can also be <input> etc..
|
|
17002
|
+
const closestElementWithAction = (el) => {
|
|
17003
|
+
if (el.hasAttribute("data-action")) {
|
|
17004
|
+
return el;
|
|
17005
|
+
}
|
|
17006
|
+
const closestDataActionElement = el.closest("[data-action]");
|
|
17007
|
+
if (!closestDataActionElement) {
|
|
17008
|
+
return null;
|
|
17009
|
+
}
|
|
17010
|
+
const visualSelector = closestDataActionElement.getAttribute(
|
|
17011
|
+
"data-visual-selector",
|
|
17012
|
+
);
|
|
17013
|
+
if (!visualSelector) {
|
|
17014
|
+
return closestDataActionElement;
|
|
17015
|
+
}
|
|
17016
|
+
const visualElement = closestDataActionElement.querySelector(visualSelector);
|
|
17017
|
+
return visualElement;
|
|
17018
|
+
};
|
|
17019
|
+
|
|
16940
17020
|
const pickConstraint = (a, b) => {
|
|
16941
17021
|
const aPrio = getConstraintPriority(a);
|
|
16942
17022
|
const bPrio = getConstraintPriority(b);
|
|
@@ -16955,60 +17035,14 @@ const getConstraintPriority = (constraint) => {
|
|
|
16955
17035
|
return 1;
|
|
16956
17036
|
};
|
|
16957
17037
|
|
|
16958
|
-
const wouldButtonClickSubmitForm = (button, clickEvent) => {
|
|
16959
|
-
if (clickEvent.defaultPrevented) {
|
|
16960
|
-
return false;
|
|
16961
|
-
}
|
|
16962
|
-
const { form } = button;
|
|
16963
|
-
if (!form) {
|
|
16964
|
-
return false;
|
|
16965
|
-
}
|
|
16966
|
-
if (!button) {
|
|
16967
|
-
return false;
|
|
16968
|
-
}
|
|
16969
|
-
const wouldSubmitFormByType =
|
|
16970
|
-
button.type === "submit" || button.type === "image";
|
|
16971
|
-
if (wouldSubmitFormByType) {
|
|
16972
|
-
return true;
|
|
16973
|
-
}
|
|
16974
|
-
if (button.type) {
|
|
16975
|
-
return false;
|
|
16976
|
-
}
|
|
16977
|
-
if (getFirstButtonSubmittingForm(form)) {
|
|
16978
|
-
// an other button is explicitly submitting the form, this one would not submit it
|
|
16979
|
-
return false;
|
|
16980
|
-
}
|
|
16981
|
-
// this is the only button inside the form without type attribute, so it defaults to type="submit"
|
|
16982
|
-
return true;
|
|
16983
|
-
};
|
|
16984
17038
|
const getFirstButtonSubmittingForm = (form) => {
|
|
16985
17039
|
return form.querySelector(
|
|
16986
17040
|
`button[type="submit"], input[type="submit"], input[type="image"]`,
|
|
16987
17041
|
);
|
|
16988
17042
|
};
|
|
16989
17043
|
|
|
16990
|
-
const wouldKeydownSubmitForm = (keydownEvent) => {
|
|
16991
|
-
if (keydownEvent.defaultPrevented) {
|
|
16992
|
-
return false;
|
|
16993
|
-
}
|
|
16994
|
-
const keydownTarget = keydownEvent.target;
|
|
16995
|
-
const { form } = keydownTarget;
|
|
16996
|
-
if (!form) {
|
|
16997
|
-
return false;
|
|
16998
|
-
}
|
|
16999
|
-
if (keydownEvent.key !== "Enter") {
|
|
17000
|
-
return false;
|
|
17001
|
-
}
|
|
17002
|
-
const isTextInput =
|
|
17003
|
-
keydownTarget.tagName === "INPUT" || keydownTarget.tagName === "TEXTAREA";
|
|
17004
|
-
if (!isTextInput) {
|
|
17005
|
-
return false;
|
|
17006
|
-
}
|
|
17007
|
-
return true;
|
|
17008
|
-
};
|
|
17009
|
-
|
|
17010
17044
|
const dispatchActionRequestedCustomEvent = (
|
|
17011
|
-
|
|
17045
|
+
elementWithAction,
|
|
17012
17046
|
{ actionOrigin = "action_prop", event, requester },
|
|
17013
17047
|
) => {
|
|
17014
17048
|
const actionRequestedCustomEvent = new CustomEvent("actionrequested", {
|
|
@@ -17019,7 +17053,7 @@ const dispatchActionRequestedCustomEvent = (
|
|
|
17019
17053
|
requester,
|
|
17020
17054
|
},
|
|
17021
17055
|
});
|
|
17022
|
-
|
|
17056
|
+
elementWithAction.dispatchEvent(actionRequestedCustomEvent);
|
|
17023
17057
|
};
|
|
17024
17058
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Constraint_validation
|
|
17025
17059
|
const requestSubmit = HTMLFormElement.prototype.requestSubmit;
|
|
@@ -17760,7 +17794,6 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
|
|
|
17760
17794
|
const Icon = ({
|
|
17761
17795
|
href,
|
|
17762
17796
|
children,
|
|
17763
|
-
className,
|
|
17764
17797
|
charWidth = 1,
|
|
17765
17798
|
// 0 (zéro) is the real char width
|
|
17766
17799
|
// but 2 zéros gives too big icons
|
|
@@ -17787,7 +17820,7 @@ const Icon = ({
|
|
|
17787
17820
|
const hasExplicitWidth = width !== undefined;
|
|
17788
17821
|
const hasExplicitHeight = height !== undefined;
|
|
17789
17822
|
if (!hasExplicitWidth && !hasExplicitHeight) {
|
|
17790
|
-
if (decorative === undefined) {
|
|
17823
|
+
if (decorative === undefined && !onClick) {
|
|
17791
17824
|
decorative = true;
|
|
17792
17825
|
}
|
|
17793
17826
|
} else {
|
|
@@ -17822,7 +17855,7 @@ const Icon = ({
|
|
|
17822
17855
|
return jsxs(Text, {
|
|
17823
17856
|
...props,
|
|
17824
17857
|
...ariaProps,
|
|
17825
|
-
className: withPropsClassName("navi_icon", className),
|
|
17858
|
+
className: withPropsClassName("navi_icon", props.className),
|
|
17826
17859
|
spacing: "pre",
|
|
17827
17860
|
"data-icon-char": "",
|
|
17828
17861
|
"data-has-width": hasExplicitWidth ? "" : undefined,
|
|
@@ -22451,6 +22484,15 @@ const InputRangeWithAction = props => {
|
|
|
22451
22484
|
});
|
|
22452
22485
|
};
|
|
22453
22486
|
|
|
22487
|
+
const SearchSvg = () => jsx("svg", {
|
|
22488
|
+
viewBox: "0 0 24 24",
|
|
22489
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22490
|
+
children: jsx("path", {
|
|
22491
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",
|
|
22492
|
+
fill: "currentColor"
|
|
22493
|
+
})
|
|
22494
|
+
});
|
|
22495
|
+
|
|
22454
22496
|
installImportMetaCss(import.meta);import.meta.css = /* css */`
|
|
22455
22497
|
@layer navi {
|
|
22456
22498
|
.navi_input {
|
|
@@ -22514,29 +22556,73 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
|
|
|
22514
22556
|
--x-background-color: var(--background-color);
|
|
22515
22557
|
--x-color: var(--color);
|
|
22516
22558
|
--x-placeholder-color: var(--placeholder-color);
|
|
22517
|
-
}
|
|
22518
22559
|
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22560
|
+
.navi_native_input {
|
|
22561
|
+
box-sizing: border-box;
|
|
22562
|
+
padding-top: var(--padding-top, var(--padding-y, var(--padding, 1px)));
|
|
22563
|
+
padding-right: var(
|
|
22564
|
+
--padding-right,
|
|
22565
|
+
var(--padding-x, var(--padding, 2px))
|
|
22566
|
+
);
|
|
22567
|
+
padding-bottom: var(
|
|
22568
|
+
--padding-bottom,
|
|
22569
|
+
var(--padding-y, var(--padding, 1px))
|
|
22570
|
+
);
|
|
22571
|
+
padding-left: var(--padding-left, var(--padding-x, var(--padding, 2px)));
|
|
22572
|
+
color: var(--x-color);
|
|
22573
|
+
background-color: var(--x-background-color);
|
|
22574
|
+
border-width: var(--x-outer-width);
|
|
22575
|
+
border-width: var(--x-outer-width);
|
|
22576
|
+
border-style: solid;
|
|
22577
|
+
border-color: transparent;
|
|
22578
|
+
border-radius: var(--x-border-radius);
|
|
22579
|
+
outline-width: var(--x-border-width);
|
|
22580
|
+
outline-style: solid;
|
|
22581
|
+
outline-color: var(--x-border-color);
|
|
22582
|
+
outline-offset: calc(-1 * (var(--x-border-width)));
|
|
22583
|
+
|
|
22584
|
+
&[type="search"] {
|
|
22585
|
+
-webkit-appearance: textfield;
|
|
22586
|
+
|
|
22587
|
+
&::-webkit-search-cancel-button {
|
|
22588
|
+
display: none;
|
|
22589
|
+
}
|
|
22590
|
+
}
|
|
22591
|
+
}
|
|
22592
|
+
|
|
22593
|
+
.navi_start_icon_label {
|
|
22594
|
+
position: absolute;
|
|
22595
|
+
top: 0;
|
|
22596
|
+
bottom: 0;
|
|
22597
|
+
left: 0.25em;
|
|
22598
|
+
}
|
|
22599
|
+
.navi_end_icon_label {
|
|
22600
|
+
position: absolute;
|
|
22601
|
+
top: 0;
|
|
22602
|
+
right: 0.25em;
|
|
22603
|
+
bottom: 0;
|
|
22604
|
+
opacity: 0;
|
|
22605
|
+
pointer-events: none;
|
|
22606
|
+
}
|
|
22607
|
+
&[data-has-value] {
|
|
22608
|
+
.navi_end_icon_label {
|
|
22609
|
+
opacity: 1;
|
|
22610
|
+
pointer-events: auto;
|
|
22611
|
+
}
|
|
22612
|
+
}
|
|
22613
|
+
|
|
22614
|
+
&[data-start-icon] {
|
|
22615
|
+
.navi_native_input {
|
|
22616
|
+
padding-left: 20px;
|
|
22617
|
+
}
|
|
22618
|
+
}
|
|
22619
|
+
&[data-end-icon] {
|
|
22620
|
+
.navi_native_input {
|
|
22621
|
+
padding-right: 20px;
|
|
22622
|
+
}
|
|
22623
|
+
}
|
|
22539
22624
|
}
|
|
22625
|
+
|
|
22540
22626
|
.navi_input .navi_native_input::placeholder {
|
|
22541
22627
|
color: var(--x-placeholder-color);
|
|
22542
22628
|
}
|
|
@@ -22615,7 +22701,52 @@ const InputStyleCSSVars = {
|
|
|
22615
22701
|
color: "--color-disabled"
|
|
22616
22702
|
}
|
|
22617
22703
|
};
|
|
22618
|
-
const InputPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
|
|
22704
|
+
const InputPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading", ":navi-has-value"];
|
|
22705
|
+
Object.assign(PSEUDO_CLASSES, {
|
|
22706
|
+
":navi-has-value": {
|
|
22707
|
+
attribute: "data-has-value",
|
|
22708
|
+
setup: (el, callback) => {
|
|
22709
|
+
const onValueChange = () => {
|
|
22710
|
+
callback();
|
|
22711
|
+
};
|
|
22712
|
+
|
|
22713
|
+
// Standard user input (typing)
|
|
22714
|
+
el.addEventListener("input", onValueChange);
|
|
22715
|
+
// Autocomplete, programmatic changes, form restoration
|
|
22716
|
+
el.addEventListener("change", onValueChange);
|
|
22717
|
+
// Form reset - need to check the form
|
|
22718
|
+
const form = el.form;
|
|
22719
|
+
const onFormReset = () => {
|
|
22720
|
+
// Form reset happens asynchronously, check value after reset completes
|
|
22721
|
+
setTimeout(onValueChange, 0);
|
|
22722
|
+
};
|
|
22723
|
+
if (form) {
|
|
22724
|
+
form.addEventListener("reset", onFormReset);
|
|
22725
|
+
}
|
|
22726
|
+
|
|
22727
|
+
// Paste events (some browsers need special handling)
|
|
22728
|
+
el.addEventListener("paste", onValueChange);
|
|
22729
|
+
// Focus events to catch programmatic changes that don't fire other events
|
|
22730
|
+
// (like when value is set before user interaction)
|
|
22731
|
+
el.addEventListener("focus", onValueChange);
|
|
22732
|
+
return () => {
|
|
22733
|
+
el.removeEventListener("input", onValueChange);
|
|
22734
|
+
el.removeEventListener("change", onValueChange);
|
|
22735
|
+
el.removeEventListener("paste", onValueChange);
|
|
22736
|
+
el.removeEventListener("focus", onValueChange);
|
|
22737
|
+
if (form) {
|
|
22738
|
+
form.removeEventListener("reset", onFormReset);
|
|
22739
|
+
}
|
|
22740
|
+
};
|
|
22741
|
+
},
|
|
22742
|
+
test: el => {
|
|
22743
|
+
if (el.value === "") {
|
|
22744
|
+
return false;
|
|
22745
|
+
}
|
|
22746
|
+
return true;
|
|
22747
|
+
}
|
|
22748
|
+
}
|
|
22749
|
+
});
|
|
22619
22750
|
const InputPseudoElements = ["::-navi-loader"];
|
|
22620
22751
|
const InputTextualBasic = props => {
|
|
22621
22752
|
const contextReadOnly = useContext(ReadOnlyContext);
|
|
@@ -22634,6 +22765,8 @@ const InputTextualBasic = props => {
|
|
|
22634
22765
|
autoFocus,
|
|
22635
22766
|
autoFocusVisible,
|
|
22636
22767
|
autoSelect,
|
|
22768
|
+
icon,
|
|
22769
|
+
cancelButton = type === "search",
|
|
22637
22770
|
...rest
|
|
22638
22771
|
} = props;
|
|
22639
22772
|
const defaultRef = useRef();
|
|
@@ -22650,10 +22783,13 @@ const InputTextualBasic = props => {
|
|
|
22650
22783
|
});
|
|
22651
22784
|
const remainingProps = useConstraints(ref, rest);
|
|
22652
22785
|
const innerOnInput = useStableCallback(onInput);
|
|
22786
|
+
const autoId = useId();
|
|
22787
|
+
const innerId = rest.id || autoId;
|
|
22653
22788
|
const renderInput = inputProps => {
|
|
22654
22789
|
return jsx(Box, {
|
|
22655
22790
|
...inputProps,
|
|
22656
22791
|
as: "input",
|
|
22792
|
+
id: innerId,
|
|
22657
22793
|
ref: ref,
|
|
22658
22794
|
type: type,
|
|
22659
22795
|
"data-value": uiState,
|
|
@@ -22684,7 +22820,15 @@ const InputTextualBasic = props => {
|
|
|
22684
22820
|
baseClassName: "navi_native_input"
|
|
22685
22821
|
});
|
|
22686
22822
|
};
|
|
22687
|
-
const renderInputMemoized = useCallback(renderInput, [type, uiState, innerValue, innerOnInput]);
|
|
22823
|
+
const renderInputMemoized = useCallback(renderInput, [type, uiState, innerValue, innerOnInput, innerId]);
|
|
22824
|
+
let innerIcon;
|
|
22825
|
+
if (icon === undefined) {
|
|
22826
|
+
if (type === "search") {
|
|
22827
|
+
innerIcon = jsx(SearchSvg, {});
|
|
22828
|
+
}
|
|
22829
|
+
} else {
|
|
22830
|
+
innerIcon = icon;
|
|
22831
|
+
}
|
|
22688
22832
|
return jsxs(Box, {
|
|
22689
22833
|
as: "span",
|
|
22690
22834
|
box: true,
|
|
@@ -22700,13 +22844,37 @@ const InputTextualBasic = props => {
|
|
|
22700
22844
|
pseudoClasses: InputPseudoClasses,
|
|
22701
22845
|
pseudoElements: InputPseudoElements,
|
|
22702
22846
|
hasChildFunction: true,
|
|
22847
|
+
"data-start-icon": innerIcon ? "" : undefined,
|
|
22848
|
+
"data-end-icon": cancelButton ? "" : undefined,
|
|
22703
22849
|
...remainingProps,
|
|
22704
22850
|
ref: undefined,
|
|
22705
22851
|
children: [jsx(LoaderBackground, {
|
|
22706
22852
|
loading: innerLoading,
|
|
22707
22853
|
color: "var(--loader-color)",
|
|
22708
22854
|
inset: -1
|
|
22709
|
-
}),
|
|
22855
|
+
}), innerIcon && jsx(Icon, {
|
|
22856
|
+
as: "label",
|
|
22857
|
+
htmlFor: innerId,
|
|
22858
|
+
className: "navi_start_icon_label",
|
|
22859
|
+
alignY: "center",
|
|
22860
|
+
color: "rgba(28, 43, 52, 0.5)",
|
|
22861
|
+
children: innerIcon
|
|
22862
|
+
}), renderInputMemoized, cancelButton && jsx(Icon, {
|
|
22863
|
+
as: "label",
|
|
22864
|
+
htmlFor: innerId,
|
|
22865
|
+
className: "navi_end_icon_label",
|
|
22866
|
+
alignY: "center",
|
|
22867
|
+
color: "rgba(28, 43, 52, 0.5)",
|
|
22868
|
+
onMousedown: e => {
|
|
22869
|
+
e.preventDefault(); // keep focus on the button
|
|
22870
|
+
},
|
|
22871
|
+
onClick: () => {
|
|
22872
|
+
uiStateController.setUIState("", {
|
|
22873
|
+
trigger: "cancel_button"
|
|
22874
|
+
});
|
|
22875
|
+
},
|
|
22876
|
+
children: jsx(CloseSvg, {})
|
|
22877
|
+
})]
|
|
22710
22878
|
});
|
|
22711
22879
|
};
|
|
22712
22880
|
const InputTextualWithAction = props => {
|
|
@@ -28496,15 +28664,6 @@ const HomeSvg = () => jsx("svg", {
|
|
|
28496
28664
|
})
|
|
28497
28665
|
});
|
|
28498
28666
|
|
|
28499
|
-
const SearchSvg = () => jsx("svg", {
|
|
28500
|
-
viewBox: "0 0 24 24",
|
|
28501
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
28502
|
-
children: jsx("path", {
|
|
28503
|
-
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",
|
|
28504
|
-
fill: "currentColor"
|
|
28505
|
-
})
|
|
28506
|
-
});
|
|
28507
|
-
|
|
28508
28667
|
const SettingsSvg = () => jsx("svg", {
|
|
28509
28668
|
viewBox: "0 0 24 24",
|
|
28510
28669
|
xmlns: "http://www.w3.org/2000/svg",
|