@metron-labs/quote-react 0.1.41 → 0.1.43

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.
@@ -0,0 +1,2 @@
1
+ /** Calls `onEscape` when Escape is pressed while `active` - for closing a dialog. */
2
+ export declare function useEscapeKey(active: boolean, onEscape: () => void): void;
@@ -0,0 +1,20 @@
1
+ import { useEffect, useRef } from "react";
2
+ /** Calls `onEscape` when Escape is pressed while `active` - for closing a dialog. */
3
+ export function useEscapeKey(active, onEscape) {
4
+ // Latest handler without re-subscribing on every render.
5
+ const handler = useRef(onEscape);
6
+ handler.current = onEscape;
7
+ useEffect(() => {
8
+ if (!active)
9
+ return;
10
+ const onKeyDown = (event) => {
11
+ // isComposing: Escape cancelling an IME composition, not meant for the dialog.
12
+ if (event.key !== "Escape" || event.defaultPrevented || event.isComposing)
13
+ return;
14
+ event.preventDefault();
15
+ handler.current();
16
+ };
17
+ document.addEventListener("keydown", onKeyDown);
18
+ return () => document.removeEventListener("keydown", onKeyDown);
19
+ }, [active]);
20
+ }
package/dist/styles.css CHANGED
@@ -948,8 +948,12 @@
948
948
 
949
949
  :where(.app-wrapper) .basket-card-stats {
950
950
  display: grid;
951
- grid-template-columns: minmax(0, 1fr) 150px 128px;
952
- align-items: end;
951
+ /* Equal qty columns so both wrap their unit (or neither) and stay aligned. */
952
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 128px;
953
+ /* Top-aligned so a wrapped unit under the qty box doesn't shift the row;
954
+ the total centres on the box via the shared height below. */
955
+ --basket-qty-h: 34px;
956
+ align-items: start;
953
957
  gap: 16px 28px;
954
958
  margin-top: 16px;
955
959
  padding-top: 5px;
@@ -979,10 +983,14 @@
979
983
  color: var(--text-dim);
980
984
  }
981
985
 
986
+ /* Wraps so the unit drops under the qty box when the host page makes the
987
+ card narrower than the viewport breakpoints expect, instead of running
988
+ into the next column. */
982
989
  :where(.app-wrapper) .basket-stat-value {
983
990
  display: flex;
991
+ flex-wrap: wrap;
984
992
  align-items: baseline;
985
- gap: 6px;
993
+ gap: 2px 6px;
986
994
  }
987
995
 
988
996
  :where(.app-wrapper) .basket-stat--right .basket-stat-value {
@@ -991,6 +999,12 @@
991
999
 
992
1000
  :where(.app-wrapper) .basket-stat--total .basket-stat-value {
993
1001
  justify-content: flex-end;
1002
+ min-height: var(--basket-qty-h);
1003
+ align-content: center;
1004
+ }
1005
+
1006
+ :where(.app-wrapper) .basket-qty-field .bom-qty-edit {
1007
+ height: var(--basket-qty-h);
994
1008
  }
995
1009
 
996
1010
  :where(.app-wrapper) .basket-stat-value--muted {
@@ -6612,11 +6626,6 @@
6612
6626
  :where(.app-wrapper) .basket-stat--total {
6613
6627
  grid-column: 1 / -1;
6614
6628
  min-width: 0;
6615
- text-align: left;
6616
- }
6617
-
6618
- :where(.app-wrapper) .basket-stat--total .basket-stat-value {
6619
- justify-content: flex-start;
6620
6629
  }
6621
6630
 
6622
6631
  /* Basket cards on narrow phones: the 90px qty box + unit overflowed its
@@ -6628,6 +6637,7 @@
6628
6637
 
6629
6638
  :where(.app-wrapper) .basket-card-stats {
6630
6639
  gap: 14px 16px;
6640
+ --basket-qty-h: 44px;
6631
6641
  }
6632
6642
 
6633
6643
  :where(.app-wrapper) .basket-stat-label {
@@ -6649,7 +6659,6 @@
6649
6659
 
6650
6660
  :where(.app-wrapper) .basket-qty-field .bom-qty-edit {
6651
6661
  width: 100%;
6652
- height: 44px;
6653
6662
  padding-left: 8px;
6654
6663
  padding-right: 36px;
6655
6664
  }
@@ -6741,17 +6750,6 @@
6741
6750
  /* Category links: one swipeable row instead of wrapping. */
6742
6751
  }
6743
6752
 
6744
- /* Small phones: basket item total sits on the right, label still above. */
6745
- @media (max-width: 400px) {
6746
- :where(.app-wrapper) .basket-stat--total {
6747
- text-align: right;
6748
- }
6749
-
6750
- :where(.app-wrapper) .basket-stat--total .basket-stat-value {
6751
- justify-content: flex-end;
6752
- }
6753
- }
6754
-
6755
6753
  /* Very small phones: logo text pushed Account/Basket onto their own row.
6756
6754
  Keep just the logo mark (the svg has a fixed px size, so font-size: 0
6757
6755
  only hides the bare text node). Footer logo is untouched. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metron-labs/quote-react",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "Metron Labs quote and estimating calculator components for React",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": [