@ox0/ui 3.1.0 → 3.1.2
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/components/combobox.d.ts.map +1 -1
- package/dist/index.js +70 -28
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAWA,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAQd,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,CACnD;IACC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,oDAAoD;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CA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EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CACrC;AA6BD,eAAO,MAAM,QAAQ,4GAgUnB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -660,22 +660,25 @@ __webpack_require__.add({
|
|
|
660
660
|
--_face-hover: var(--_face);
|
|
661
661
|
--_fg: var(--ox0-color-foreground);
|
|
662
662
|
--_edge: transparent;
|
|
663
|
+
--_edge-bottom: var(--_edge);
|
|
663
664
|
--_sheen: transparent;
|
|
664
665
|
--_bevel: transparent;
|
|
665
666
|
--_ink-face: 100%;
|
|
666
667
|
--_ink-edge: 100%;
|
|
667
668
|
--_ink-fg: 100%;
|
|
668
|
-
--_cast-
|
|
669
|
-
--_cast-
|
|
669
|
+
--_cast-tint: light-dark(color-mix(in oklab, var(--ox0-ref-shadow) 55%, #604226), var(--ox0-ref-shadow));
|
|
670
|
+
--_cast-1: light-dark(color-mix(in srgb, var(--_cast-tint) 24%, transparent), color-mix(in srgb, var(--_cast-tint) 50%, transparent));
|
|
671
|
+
--_cast-2: light-dark(color-mix(in srgb, var(--_cast-tint) 26%, transparent), color-mix(in srgb, var(--_cast-tint) 60%, transparent));
|
|
670
672
|
--_shade: light-dark(color-mix(in srgb, var(--ox0-ref-shadow) 7%, transparent), color-mix(in srgb, var(--ox0-ref-shadow) 18%, transparent));
|
|
671
673
|
--_shade-strong: light-dark(color-mix(in srgb, var(--ox0-ref-shadow) 22%, transparent), color-mix(in srgb, var(--ox0-ref-shadow) 50%, transparent));
|
|
672
674
|
--_ledge-max: 0px;
|
|
673
675
|
--_ledge: var(--_ledge-max);
|
|
674
676
|
--_ledge-color: transparent;
|
|
675
677
|
--_drop: 0px;
|
|
678
|
+
--_travel: var(--ox0-duration-fast);
|
|
676
679
|
--_shadow-up: inset 0 1px 0 var(--_bevel), 0 var(--_ledge) 0 var(--_ink-ledge),
|
|
677
680
|
0 calc(var(--_ledge) + 1px) 1px var(--_ink-cast-1),
|
|
678
|
-
0 calc(var(--_ledge) + 2px)
|
|
681
|
+
0 calc(var(--_ledge) + 2px) 6px -1px var(--_ink-cast-2);
|
|
679
682
|
--_shadow-down: inset 0 1px 0 var(--_bevel), 0 0 0 var(--_ink-ledge), 0 0 1px var(--_ink-cast-1),
|
|
680
683
|
0 0 0 0 transparent;
|
|
681
684
|
--_shadow-held: inset 0 1px 2px var(--_shade-strong), 0 0 0 var(--_ink-ledge), 0 0 1px var(--_ink-cast-1),
|
|
@@ -720,17 +723,35 @@ __webpack_require__.add({
|
|
|
720
723
|
pointer-events: none;
|
|
721
724
|
transition: background-color var(--ox0-duration-fast) var(--ox0-ease-soft),
|
|
722
725
|
border-color var(--ox0-duration-fast) var(--ox0-ease-soft),
|
|
723
|
-
bottom var(--
|
|
724
|
-
box-shadow var(--
|
|
725
|
-
top var(--
|
|
726
|
+
bottom var(--_travel) var(--ox0-ease-soft),
|
|
727
|
+
box-shadow var(--_travel) var(--ox0-ease-soft),
|
|
728
|
+
top var(--_travel) var(--ox0-ease-soft);
|
|
726
729
|
z-index: -1;
|
|
727
730
|
position: absolute;
|
|
728
731
|
}
|
|
729
732
|
|
|
733
|
+
.button-gV6kKp:after {
|
|
734
|
+
background: linear-gradient(to bottom,
|
|
735
|
+
transparent calc(100% - var(--_radius)),
|
|
736
|
+
color-mix(in srgb, var(--_edge-bottom) var(--_ink-edge), transparent))
|
|
737
|
+
border-box;
|
|
738
|
+
border-radius: inherit;
|
|
739
|
+
box-sizing: border-box;
|
|
740
|
+
content: "";
|
|
741
|
+
inset: calc(var(--_ledge-max) - var(--_ledge)) 0 var(--_ledge);
|
|
742
|
+
pointer-events: none;
|
|
743
|
+
transition: bottom var(--_travel) var(--ox0-ease-soft),
|
|
744
|
+
top var(--_travel) var(--ox0-ease-soft);
|
|
745
|
+
z-index: -1;
|
|
746
|
+
border: 1px solid #0000;
|
|
747
|
+
position: absolute;
|
|
748
|
+
mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0);
|
|
749
|
+
}
|
|
750
|
+
|
|
730
751
|
.content-A8tTMi {
|
|
731
752
|
align-items: center;
|
|
732
753
|
gap: var(--_gap);
|
|
733
|
-
transition: translate var(--
|
|
754
|
+
transition: translate var(--_travel) var(--ox0-ease-soft);
|
|
734
755
|
translate: 0 calc(var(--_ledge-max) - var(--_ledge) + var(--_drop));
|
|
735
756
|
will-change: translate;
|
|
736
757
|
display: inline-flex;
|
|
@@ -794,6 +815,10 @@ __webpack_require__.add({
|
|
|
794
815
|
padding-inline: 0;
|
|
795
816
|
}
|
|
796
817
|
|
|
818
|
+
.pressed-egzbhE {
|
|
819
|
+
--_travel: var(--ox0-duration-instant);
|
|
820
|
+
}
|
|
821
|
+
|
|
797
822
|
.primary-VXuTnQ, .secondary-yGEbH1, .danger-S8YoTI, .danger-secondary-SKDzBf {
|
|
798
823
|
--_ledge-max: 1px;
|
|
799
824
|
--_shadow: var(--_shadow-up);
|
|
@@ -820,25 +845,25 @@ __webpack_require__.add({
|
|
|
820
845
|
}
|
|
821
846
|
|
|
822
847
|
.secondary-yGEbH1 {
|
|
823
|
-
--_face: var(--ox0-color-surface-raised);
|
|
824
|
-
--_face-hover: color-mix(in srgb,
|
|
825
|
-
var(--ox0-color-surface-raised) 95%,
|
|
826
|
-
var(--ox0-color-foreground));
|
|
848
|
+
--_face: light-dark(var(--ox0-color-surface-raised), color-mix(in srgb, var(--ox0-color-surface-raised) 72%, var(--ox0-ref-shadow)));
|
|
849
|
+
--_face-hover: color-mix(in srgb, var(--_face) 95%, var(--ox0-color-foreground));
|
|
827
850
|
--_fg: var(--ox0-color-foreground);
|
|
828
851
|
--_edge: light-dark(color-mix(in srgb, var(--ox0-color-border) 70%, var(--ox0-color-border-strong)), color-mix(in srgb, var(--ox0-ref-shadow) 55%, var(--ox0-color-border)));
|
|
829
|
-
--
|
|
830
|
-
--
|
|
831
|
-
--
|
|
852
|
+
--_edge-bottom: light-dark(var(--ox0-color-border-strong), color-mix(in srgb, var(--ox0-ref-shadow) 70%, var(--ox0-color-border)));
|
|
853
|
+
--_ledge-color: light-dark(color-mix(in srgb, var(--ox0-color-border-strong) 88%, var(--_cast-tint)), color-mix(in srgb, var(--ox0-ref-shadow) 80%, var(--ox0-color-border)));
|
|
854
|
+
--_sheen: light-dark(#ffffff8c, #ffffff05);
|
|
855
|
+
--_bevel: light-dark(#fffc, #ffffff29);
|
|
832
856
|
}
|
|
833
857
|
|
|
834
858
|
.danger-secondary-SKDzBf {
|
|
835
|
-
--_face: var(--ox0-color-surface-raised);
|
|
859
|
+
--_face: light-dark(var(--ox0-color-surface-raised), color-mix(in srgb, var(--ox0-color-surface-raised) 72%, var(--ox0-ref-shadow)));
|
|
836
860
|
--_face-hover: var(--ox0-color-danger-subtle);
|
|
837
861
|
--_fg: var(--ox0-color-danger);
|
|
838
862
|
--_edge: color-mix(in srgb, var(--ox0-color-danger) 40%, var(--ox0-color-border));
|
|
839
|
-
--
|
|
840
|
-
--
|
|
841
|
-
--
|
|
863
|
+
--_edge-bottom: light-dark(color-mix(in srgb, var(--ox0-color-danger) 48%, var(--ox0-color-border)), color-mix(in srgb, var(--ox0-color-danger) 45%, var(--ox0-ref-shadow)));
|
|
864
|
+
--_ledge-color: light-dark(color-mix(in srgb, var(--ox0-color-danger) 55%, var(--ox0-color-border)), color-mix(in srgb, var(--ox0-color-danger) 35%, var(--ox0-ref-shadow)));
|
|
865
|
+
--_sheen: light-dark(#ffffff8c, #ffffff05);
|
|
866
|
+
--_bevel: light-dark(#fffc, #ffffff29);
|
|
842
867
|
}
|
|
843
868
|
|
|
844
869
|
.primary-VXuTnQ:not(:disabled):hover, .secondary-yGEbH1:not(:disabled):hover, .danger-S8YoTI:not(:disabled):hover, .danger-secondary-SKDzBf:not(:disabled):hover {
|
|
@@ -853,12 +878,13 @@ __webpack_require__.add({
|
|
|
853
878
|
.ghost-jToGzF, .flat-WzquwN, .circle-Hk06Xp {
|
|
854
879
|
--_cast-1: transparent;
|
|
855
880
|
--_cast-2: transparent;
|
|
881
|
+
--_shadow: var(--_shadow-down);
|
|
856
882
|
--_fg: color-mix(in srgb, var(--ox0-color-foreground) 82%, transparent);
|
|
857
883
|
}
|
|
858
884
|
|
|
859
885
|
.flat-WzquwN {
|
|
860
886
|
--_edge: var(--ox0-color-border);
|
|
861
|
-
--_sheen: light-dark(#
|
|
887
|
+
--_sheen: light-dark(#fff6, #ffffff03);
|
|
862
888
|
--_bevel: light-dark(#fff9, #ffffff09);
|
|
863
889
|
--_shadow: var(--_shadow-down);
|
|
864
890
|
}
|
|
@@ -874,6 +900,10 @@ __webpack_require__.add({
|
|
|
874
900
|
--_fg: var(--ox0-color-foreground);
|
|
875
901
|
}
|
|
876
902
|
|
|
903
|
+
.flat-WzquwN:not(:disabled):hover {
|
|
904
|
+
--_sheen: light-dark(#ffffffbf, #ffffff06);
|
|
905
|
+
}
|
|
906
|
+
|
|
877
907
|
.ghost-jToGzF:not(:disabled).pressed-egzbhE, .flat-WzquwN:not(:disabled).pressed-egzbhE, .circle-Hk06Xp:not(:disabled).pressed-egzbhE {
|
|
878
908
|
--_drop: 1px;
|
|
879
909
|
--_face: color-mix(in srgb, var(--ox0-color-foreground) 11%, transparent);
|
|
@@ -961,12 +991,12 @@ __webpack_require__.add({
|
|
|
961
991
|
hasIcon: "hasIcon-AtG6pQ",
|
|
962
992
|
hasIconEnd: "hasIconEnd-PZ2yhA",
|
|
963
993
|
iconOnly: "iconOnly-OzYHgJ",
|
|
994
|
+
pressed: "pressed-egzbhE",
|
|
964
995
|
primary: "primary-VXuTnQ",
|
|
965
996
|
secondary: "secondary-yGEbH1",
|
|
966
997
|
danger: "danger-S8YoTI",
|
|
967
998
|
"danger-secondary": "danger-secondary-SKDzBf",
|
|
968
999
|
dangerSecondary: "danger-secondary-SKDzBf",
|
|
969
|
-
pressed: "pressed-egzbhE",
|
|
970
1000
|
ghost: "ghost-jToGzF",
|
|
971
1001
|
flat: "flat-WzquwN",
|
|
972
1002
|
circle: "circle-Hk06Xp",
|
|
@@ -6415,6 +6445,10 @@ const combobox_module = combobox_module_0.A && combobox_module_0.A.locals ? comb
|
|
|
6415
6445
|
function labelFor(options, value) {
|
|
6416
6446
|
return options.find((o)=>o.value === value)?.label ?? "";
|
|
6417
6447
|
}
|
|
6448
|
+
function combobox_firstEnabled(options) {
|
|
6449
|
+
const index = options.findIndex((o)=>!o.disabled);
|
|
6450
|
+
return -1 === index ? null : index;
|
|
6451
|
+
}
|
|
6418
6452
|
function matchLabel(options, text) {
|
|
6419
6453
|
const q = text.trim().toLowerCase();
|
|
6420
6454
|
return options.find((o)=>!o.disabled && o.label.toLowerCase() === q);
|
|
@@ -6424,7 +6458,7 @@ function filterOptions(options, inputText) {
|
|
|
6424
6458
|
if (!q) return options;
|
|
6425
6459
|
return options.filter((o)=>o.label.toLowerCase().includes(q));
|
|
6426
6460
|
}
|
|
6427
|
-
const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel, description, isDisabled, isInvalid, errorMessage, options, value: valueProp, defaultValue, placeholder, onChange, noOptionsMessage = "No options", allowsCustomValue = false, id: idProp, ...inputProps }, forwardedRef) {
|
|
6461
|
+
const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel, description, isDisabled, isInvalid, errorMessage, options, value: valueProp, defaultValue, placeholder, onChange, noOptionsMessage = "No options", allowsCustomValue = false, id: idProp, onBlur: onBlurProp, onFocus: onFocusProp, onKeyDown: onKeyDownProp, onPointerDown: onPointerDownProp, ...inputProps }, forwardedRef) {
|
|
6428
6462
|
if (!label && !ariaLabel) throw new Error("Combobox requires `label` or `ariaLabel`.");
|
|
6429
6463
|
const generatedId = useId();
|
|
6430
6464
|
const controlId = idProp ?? generatedId;
|
|
@@ -6510,15 +6544,17 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel,
|
|
|
6510
6544
|
setInputText(text);
|
|
6511
6545
|
setIsFiltering(true);
|
|
6512
6546
|
setIsOpen(true);
|
|
6513
|
-
setActiveIndex(null);
|
|
6547
|
+
setActiveIndex(text.trim() ? combobox_firstEnabled(filterOptions(options, text)) : null);
|
|
6514
6548
|
if (allowsCustomValue) {
|
|
6515
6549
|
prevSelectedRef.current = text;
|
|
6516
6550
|
commit(text);
|
|
6517
6551
|
}
|
|
6518
6552
|
}
|
|
6519
6553
|
function handleKeyDown(e) {
|
|
6554
|
+
onKeyDownProp?.(e);
|
|
6555
|
+
if (e.defaultPrevented) return;
|
|
6520
6556
|
if ("Enter" === e.key) {
|
|
6521
|
-
const opt = null
|
|
6557
|
+
const opt = null !== activeIndex && isOpen ? filteredOptions[activeIndex] : void 0;
|
|
6522
6558
|
if (void 0 === opt && allowsCustomValue) return void setIsOpen(false);
|
|
6523
6559
|
if (opt && !opt.disabled) selectOption(opt);
|
|
6524
6560
|
e.preventDefault();
|
|
@@ -6531,7 +6567,11 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel,
|
|
|
6531
6567
|
setActiveIndex(null);
|
|
6532
6568
|
} else if (("ArrowDown" === e.key || "ArrowUp" === e.key) && !isOpen) open();
|
|
6533
6569
|
}
|
|
6534
|
-
function handleBlur() {
|
|
6570
|
+
function handleBlur(e) {
|
|
6571
|
+
commitText();
|
|
6572
|
+
onBlurProp?.(e);
|
|
6573
|
+
}
|
|
6574
|
+
function commitText() {
|
|
6535
6575
|
const matched = matchLabel(options, inputText);
|
|
6536
6576
|
if (allowsCustomValue && !matched) {
|
|
6537
6577
|
const text = inputText.trim();
|
|
@@ -6546,7 +6586,7 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel,
|
|
|
6546
6586
|
}
|
|
6547
6587
|
const [isFocusVisible, setIsFocusVisible] = useState(false);
|
|
6548
6588
|
const pointerDown = useRef(false);
|
|
6549
|
-
const activeDescendant = null !== activeIndex && filteredOptions[activeIndex] ? `${listboxId}-${
|
|
6589
|
+
const activeDescendant = null !== activeIndex && filteredOptions[activeIndex] ? `${listboxId}-option-${activeIndex}` : void 0;
|
|
6550
6590
|
return /*#__PURE__*/ jsxs("div", {
|
|
6551
6591
|
className: combobox_module.root,
|
|
6552
6592
|
children: [
|
|
@@ -6588,13 +6628,15 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel,
|
|
|
6588
6628
|
onChange: handleInputChange,
|
|
6589
6629
|
onKeyDown: handleKeyDown,
|
|
6590
6630
|
onBlur: handleBlur,
|
|
6591
|
-
onPointerDown: ()=>{
|
|
6631
|
+
onPointerDown: (e)=>{
|
|
6592
6632
|
pointerDown.current = true;
|
|
6633
|
+
onPointerDownProp?.(e);
|
|
6593
6634
|
},
|
|
6594
|
-
onFocus: ()=>{
|
|
6635
|
+
onFocus: (e)=>{
|
|
6595
6636
|
if (!pointerDown.current) setIsFocusVisible(true);
|
|
6596
6637
|
pointerDown.current = false;
|
|
6597
6638
|
open();
|
|
6639
|
+
onFocusProp?.(e);
|
|
6598
6640
|
},
|
|
6599
6641
|
onBlurCapture: ()=>setIsFocusVisible(false)
|
|
6600
6642
|
}),
|
|
@@ -6636,7 +6678,7 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ label, ariaLabel,
|
|
|
6636
6678
|
optionRefs.current[index] = node;
|
|
6637
6679
|
},
|
|
6638
6680
|
...getItemProps({
|
|
6639
|
-
id: `${listboxId}-${
|
|
6681
|
+
id: `${listboxId}-option-${index}`,
|
|
6640
6682
|
role: "option",
|
|
6641
6683
|
"aria-selected": option.value === selectedValue,
|
|
6642
6684
|
"aria-disabled": option.disabled,
|